FAQ Database Discussion Community


Decode Json Object Php

php,android,json,decode
My json data looks like this : { "amount":550, "items":[ {"item_id":12334, "price": 504}, {"item_id":12335, "price":206} ] } I want to know how to parse this data in order to fetch each information in separate variable....

why can't I import seperately from the method decleration?(java)

java,eclipse,import,base64,decode
I wrote a simple program to decode a base64 encoded String I have. I searched using eclipse for a method to do that and found out that the method javax.xml.bind.DatatypeConverter.parseBase64Binary(String s) does esactly that. I found out that when I'm using the full location of the method, the program is...

How to convert text to Base58 on node.js?

javascript,node.js,encryption,decode,encode
I want to convert a message like "Hello World" to base58 and then been able to decode it using node.js.Base-58 module has the below explanation but I can't exactly understand how to convert my message. Base58.encode(a Buffer or Uint8Array) returns a String Base58.decode(a String) returns a Buffer I guess that...

How to parse nested json to php

php,json,decode
{ "status": "success", "photos": [ { "width": 640, "height": 640, "tags": [ { "uids": [ ], "label": null, "confirmed": false, "manual": false, "width": 27.81, "height": 27.81, "yaw": 0, "roll": -12, "pitch": 0, "attributes": { "face": { "value": "true", "confidence": 69 } }, "points": null, "similarities": null, "tid": "[email protected]_a8ecc6434914f_47.66_30.00_0_1", "recognizable": true,...

How to convert a Base64 string to Bitmap on Android?

android,json,base64,decode
I'm having this problem for converting several Base64 string to Bitmap images, in my android application. Now I've looked for solutions for quite a while, but nothing seems to solve my problem. My application gets JSON data from a server, containing several images in base64. the json code received from...

UnicodeDecodeError when sending the result of a function in CherryPy

python,unicode,decode,encode,cherrypy
Hı All, I want to send a string variable to web app. Normally, I can send a string without any problem when I create it manually inside the 'switch' part of the code. But when I obtain that string from a function, I get an error. I mean, if counterstring='12.3'...

saving base64 decoded string into a zip file

java,string,zip,base64,decode
I am trying to save a base64 decoded string into a zip file using the mentioned code: Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/home/wemohamm/Desktop/test.zip"))); out.write(decodedString); out.close(); Here decodedString contains base64 decoded string and I can output it. I am running the code in rhel6 with Java 1.6. When I try...

Base64-decode a string using NetEncoding in Delphi XE7?

delphi,base64,decode,delphi-xe7,utf8-decode
In Delphi XE7 Update 1, when trying to execute this code in a VCL program: uses System.NetEncoding; ... tempstring := TNetEncoding.Base64.Decode(tempstring); I get this error message: So how can I base64-decode a string using NetEncoding?...

How to resize an image an cut the excess area of it in Python?

python,python-2.7,base64,decode,encode
I have a string which contains the base64 code of an image. I need to resize this image to 591x608px, but I don't want it to be deformed if it has a different scale. I don't know if this is the best way (please, correct me if there is a...

why I can't decode the ‘utf8’ string in python2.7?

python,python-2.7,utf-8,standards,decode
I use python write: '\xF5\x90\x90\x90'.decode('utf8') But it make error: UnicodeDecodeError: 'utf8' codec can't decode byte 0xf5 in position 0: invalid start byte The string\xF5\x90\x90\x90 is a standard 'utf8' string. It's binary is 11110101 10010000 10010000 10010000. Comply with the rules of utf8 :11110xxx 10xxxxxx 10xxxxxx 10xxxxxx why I can't decode...

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

python,python-2.7,utf-8,decode
I'm simply trying to decode \uXXXX\uXXXX\uXXXX-like string. But I get an error: $ python Python 2.7.6 (default, Sep 9 2014, 15:04:36) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> print u'\u041e\u043b\u044c\u0433\u0430'.decode('utf-8') Traceback (most recent call last): File "<stdin>", line...

How can I parse this JSON with PHP?

php,html,json,parsing,decode
How can I parse this JSON, which is supposed to display the items a user has in their Steam inventory. I have tried this: $data = file_get_contents('http://steamcommunity.com/id/Mitch8910/inventory/json/440/2/'); $json = json_decode($data); echo $data; It returns the same as just visiting the link. I can't get anything like this to work either:...

How to get decode this attachment filename with python?

python,decode,email-attachments,email-headers
I already decoded a lot of email attachments filenames in my code. But this particular filename breaks my code. Here is a minimal example: from email.header import decode_header encoded_filename='=?UTF-8?B?U2FsZXNJbnZvaWNl?==?UTF-8?B?LVJlcG9ydC5wZGY=?=' decoded_header=decode_header(encoded_filename) # --> [('SalesInvoiceQ1|\x04\xb5I\x95\xc1\xbd\xc9\xd0\xb9\xc1\x91\x98', 'utf-8')] filename=str(decoded_header[0][0]).decode(decoded_header[0][1]) Exception: UnicodeDecodeError: 'utf8' codec can't decode byte 0xb5 in position 16: invalid start...

How to decode raw data (non-ascii char) from a barcode scanner

java,vb.net,decode,barcode
Me and my dev team have a project that .... us from using a handheld barcode scanner. In order to do the job we have to convert the barcode scanner signal into a raw data and send that data trough RS232 to our PC and then process it with VB.net...

Json API -> Trying to get property of non-object

php,json,object,decode
I have read lots of different articles on this but can't seem to find a solution that works. I'm currently working on getting json data from an API (I have to authorize the connection first) and outputting data from it. (only bits and pieces, like name, id, etc., not the...

Error decoding animated webp iOS

ios,objective-c,decode,webp
I've been struggling for two days to display an animated webp image in a UIImageView with no success whatsoever. Mainly the problem is in the decoding step of the file which gives this error: VP8_STATUS_UNSUPPORTED_FEATURE. I tried https://github.com/seanooi/iOS-WebP https://github.com/mattt/WebPImageSerialization These projects provide code for creating UIImage with webp files and...

String decoding

string,decode
I have this string that should contain XML information, but I don't know how it has been encoded....

base64_decode return null when trying to upload image

java,php,base64,decode
I am trying to upload an image to server but base64_decode always returns null i read a lot of different cases from SO but nothing works. here is my java code before i make my http request: ByteArrayOutputStream stream = new ByteArrayOutputStream(); // Must compress the Image to reduce image...

How to convert a binary representation of a string back to the original string in Python?

python,decode,binary-data
I haven't been able to find an answer to the following question: Start with a string, convert it to its binary representation. How do you get back the original string in Python? Example: a = 'hi us' b = ''.join(format(ord(c), '08b') for c in a) then b = 0110100001101001001000000111010101110011 Now...

How to decode a live555 rtsp stream (h.264) MediaSink data using iOS8's VideoToolbox?

ios,decode,h.264,rtsp,live555
Ok, I know that this question is almost the same as get-rtsp-stream-from-live555-and-decode-with-avfoundation, but now VideoToolbox for iOS8 became public for use and although I know that it can be done using this framework, I have no idea of how to do this. My goals are: Connect with a WiFiCamera using...

How to find and delete the duplciates on array of json

php,arrays,json,decode,encode
How can i find and delete the duplicates on [{"id":"1","name":"raj"},{"id":"2","name":"antony"},{"id":"1","name":"raj"}] Here How can i replace the duplicate entry i.e., {"id":"1","name":"raj"} So, my output should be [{"id":"1","name":"raj"},{"id":"2","name":"antony"}] ...

Character encoding/decoding returns ? signs or weird results when form is submitted

php,utf-8,character-encoding,decode,utf8mb4
I know there are many similar posts about this but so far I couldn't solve my problem although I went thru them. I'm trying to print exact search keywords when I hit Search button but unfortunately I'm seeing encoded versions and I cannot decode. I read up on utf8_decode and...

Translate encoding of string

clojure,character-encoding,decode,windows-1252
I have a string that is in Windows-1252 encoding, but needs to be converted to UTF-8. This is for a program that fixes a UTF-8 file that has fields containing Russian text encoded in quoted-printable Windows-1252. Here's the code that decodes the quoted-printable: (defn reencode [line] (str/replace line #"=([0-9A-Fa-f]{2})=([0-9A-Fa-f]{2})" (fn...

json_decode with array and objects

php,arrays,json,object,decode
I have JSON that I need to get some information from. <? $json = {"ship":{"shipname":"Harbinger Navy Issue","shipid":"33155","dna":"33155:3520;6:11561;1:19280;1:19278;1:4349;1:19191;1:2364;2:1248;3:2048;1:31372;3:2488;10:12814;6::"},"high":[{"Heavy Pulse Laser II:3520":6}],"medium":[{"Shield Boost Amplifier I:11561":1},{"Pith A-Type EM Ward Field:19280":1},{"Pith A-Type Thermic Dissipation Field:19278":1},{"Pithum C-Type Adaptive Invulnerability Field:4349":1},{"Pithum A-Type Medium Shield Booster:19191":1}],"low":[{"Heat Sink...

How to decode bencoded torrent data

python,python-2.7,decode,bittorrent,bencoding
I'm trying to extract size and name from a torrent file with decoding the content of a torrent file with bencode. I did pip install bencode then I tested with one of the line of a torrent file as you can see there. import bencode blabla = 'd8:announce70:http://tracker.t411.io:56969/c5faa6720249d33ff6ba2af48640af89/announce7:comment29:https://www.t411.io/t/524280210:created by19:https://www.t411.io13:creation datei1431685353e4:infod6:lengthi14634059e4:name22:Charlie-Hebdo-1178.pdf12:piece...

Python buffer decode

python,buffer,decode,encode
I have a UDP package that is sent from a C++ program and I have to read it in Python. I managed to receive the UDP package but unfortunately it is encoded. The C++ data has the form struct packet{ double arg1 double arg2 double arg3 double arg4 int16_t arg5...

Adding Å,Ä and Ö to sqlite table through python 2.7, cgi and html post

python,sqlite,python-2.7,cgi,decode
I'm using cgi, python 2.7 and sqlite. I'm trying to insert an string? that contains the characters å,ä and ö into an sqlite table. the string are taken from an html post using cgi this code in takes the value: print '<form action="./printusername.cgi" method="post">' print 'First Name: <input type="text" name="first_name">'...

PHP encode/decode string only numbers and characters

php,hash,encoding,decode,encode
I know about the PHP function encode() and decode(), they work well for me, but I want to pass the encoded string inside an url, but encode does return special chars like "=" "," "'" etc.... This does obviously break my script, what would be the best way to encode...

How to create a pandas dataframe containing columns with special characters?

python,pandas,decode,encode
I try to create a Pandas data-frame from a list of dictionaries: df = pandas.DataFrame(ls, columns = cols) As a result I get the following error message: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128) I assume that the errors is caused by the...

How to get the value for the given json and get result

php,arrays,json,decode,encode
I am trying to get the result for the below query $users = DB::select("SELECT FIND_IN_SET('l','a,b,c,d') as Res"); and while i do return $users; Here is my json [{"Res":0}] When i try to decode it, it shows me the error json_decode() expects parameter 1 to be string, array given When i...

How to decode route parameters in Sinatra?

parameters,routes,sinatra,decode
I have implemented a simple route : get '/test' do params end When I call it without encoded parameters like /test?plip=plop => ["plip", "plop"] I am able to retrieve my parameter without any problem. However, with encoded parameters : /test?plip%3Dplop => ["plip=plop", nil] the key/value does not match anymore. Do...

file_get_contents(JSON) not working for valid URL

php,html,json,decode
I'm trying to get a JSON from a ULR, but I get the error: Warning: file_get_contents(http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=StatTrak™ Five-SeveN | Copper Galaxy (Factory New)): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error in F:\Bitnami\htdocs\Dreamweaver\freehtml5streets\updateInventory.php on line 70 This is the URL I'm trying to use, as you can...

encode string in Python 3 without unicode \xc2 subsitution

python,string,unicode,decode,encode
So I was writing some code for some communication with a piece of hardware vis pySerial and i was using python 2.7.7 and everything worked fine, i switched to python 3.4 cause i issues with getting a GUI "framework" installed. So the problem i have is that I have to...

How to use Oracle's decode function in where clause

sql,oracle,decode,nvl
I have a query with few filter criteria, one of them is get to the query as integer parameter. I want to use this filter only if this integer is > 0 I can't use NVL as it will never be null. How can I use DECODE in such case?...

json_decode() expects parameter 1 to be string, array given

arrays,json,twitter,decode
I have the following code, in which I am getting Tweets in JSON format on an HTML page, I want this to be displayed neatly on an HTML page. I have included the foreach loop, however I am getting the following error: " json_decode() expects parameter 1 to be string,...

Decode image to bitmap ok, but why?

image,bitmap,png,decode
I would like to know why we need to decode let's say a png to a bitmap in order to show the image. Why not just show the png like that (encoded). I'm asking here a moron type of question on purpose. It's clear to me it's impossible to show...

Decompress a JPEG DICOM image starting from PixelData values (DCMTK)

c++,visual-studio-2013,decode,dicom,dcmtk
I want to decompress a DICOM file using DCMTK like in this example http://support.dcmtk.org/docs/mod_dcmjpeg.html But my problem is that I don't want to load a file. I have an array which inside there are the PixelData values Compressed. I have tried in this way but doesn't work. DJDecoderRegistration::registerCodecs(); DJEncoderRegistration::registerCodecs(); DcmFileFormat...

json_decode() when there are multiple results

php,json,decode
I am trying to get my head around how I can get the SKU's (and additionally the ID) from json results. I can do this when there are just one set of values called SKU but I have spent hours trying to understand how to do this when there are...

Split String by comma separated , but not able to find generic solution

java,regex,string,parsing,decode
String str = "\"{\"\"oman\"\"\",333,333,Locationoman,1,NULL,3.33333E+15,0,NULL,-1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,,NULL,NULL,NULL,1,NULL,50036,1.42771E+12,0,NULL,0,NULL,NULL,NULL,,NULL,NULL,NULL,NULL,2,0,1,3,0,1,T,F,F,0,Volume,-1,302,50036,50036,0,0,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,3,NULL,NULL,NULL,2,1,1,1,3,1,1,1,50036,0,1,0,OmanPrepaid,0,blrfts186_f861,CCC_USER_257,a082000000000033,\"16,436,113,650\",,NULL}"; I Have a String like this, but the output should be like...

Convert Bitmap from array of bytes (byte[]) - Bitmap is still null

android,bitmap,jni,bytearray,decode
I have a byte array retrieved from JNI part of my application. The input to JNI was also a byte array of bitmap picture from camera in ARGB8888 format. C++ has modified my bitmap to grayscale, using FastCV function. Here is my code: Java: private void fcvTest(String fileName) { //path...

Oracle SQL — decode to multiple elements

sql,oracle,decode
I might make a join condition like: table1.value_1 = decode(table2.encoded_value,1,'a',2,'b',3,'c') But what if I need to do an in-type join? e.g. How could I write a decode to accomplish the functionality of, say: table1.value_1 in decode(table2.encoded_value, 1, 'a', 2, 'b', 3, 'c', 4, ('d','e','f') ); This syntax is not valid,...

Issue with Encoding base64 in PHP and Decoding base64 in Java

java,encoding,character-encoding,decode,string-decoding
A string-"gACA" encoded in PHP using base64. Now I'm trying to decode in java using base64. But getting absurd value after decoding. I have tried like this: public class DecodeString{ { public static void main(String args[]){ String strEncode = "gACA"; //gACA is encoded string in PHP byte byteEncode[] = com.sun.org.apache.xerces.internal.impl.dv.util.Base64.decode(strEncode...

Basic Unicode encoding/decoding

python,unicode,decode,encode
Python 2.7.9 / Windows environment when I print myString I'm seeing: u'\u5df1\u6b66\u8d2a\u5929\u66f2' Now I know the console I'm using (git-bash) is capable of displaying unicode. How can I encode (or decode, which ever is the right process to do) myString so that it displays: 己武贪天曲 I understand that the question...

Should I BIO_flush() after BIO_read()-ing?

openssl,base64,decode,flush,decoder
So I implement a base64 decoder and while encoding (BIO_write() on BIO_f_base64) you should BIO_flush() as they say in documentation. However, they don't mention anything regarding BIO_read() (decoding). Should I flush after BIO_read() and if not what are the consequences if I do?

Extract part of data from JSON file with python

python,json,dictionary,extract,decode
I have been trying to extract only certain data from a JSON file. I managed to decode the JSON and get the wanted data into a python dict. When I print out the dict it shows all the wanted data, but when I try to write the dict into a...

unable to decode stream while selecting an image

android,image,decode,android-bitmap
While selecting an image from a gallery in my application it doesn't crash but instead its unable to decode the stream of the path. Taking the picture directly from the camera is working fine but from the gallery its not here is my code in my activity result . //enter...

Python 3 Socket, can't receive data (encode, decode)

python,sockets,decode,encode
I have a game and I was working with some networking to make it multiplayer. I created a custom module (not the best in any way), to convert two values (XY) from -1048576 to +1048576 and a value from 0 to 60 (health), into 6 characters. So in 6 bytes...

Decode hex string to latin characters [duplicate]

php,hex,decode
This question already has an answer here: How to convert HTML entities like &#8211; to their character equivalents? 4 answers I have string: &#x74;&#x6f;&#x6d;&#x61;&#x73; there is decoded string tomas I found that there is hec decode type : http://www.codetable.net/unicodecharacters Does in PHP exists fuction to encode hex to latin...

php turn this syntax into object/array

php,arrays,string,object,decode
Is there a way of turning this: network={ ssid="tele2-ssid-66577" #psk="testtest2" psk=8308d8e34c60fe471fda6837ab5821694e8cf51a655f24295797df33d02df6e9 } into an object or an array with php? I tried json_decode with no result. ------------- UPDATE: the end goal is to extract only the psk key, I just thought turning it into an object/array would be the easiest...

Google maps v3 decode polygon(s) from MySQL database

mysql,xml,google-maps,polygon,decode
I would like to draw one or more polygons which are saved encoded in the MySQL database. I've based my code on the known bermudatriangle script example. The XML from "polygon_xml.php" is OK. For now, there's only 1 encoded coordinate in the database. At: //alert1(decodedPolygon); the coordinates are shown, but...

ascii codec cant decode byte 0xe9

python,unicode,encoding,utf-8,decode
I have done some research and seen solutions but none have worked for me. Python - 'ascii' codec can't decode byte This didn't work for me. And I know the 0xe9 is the é character. But I still can't figure out how to get this working, here is my code...

What is the difference between DecodePixelWidth Vs. ScaleTransform?

c#,.net,decode,pixel,scaletransform
I'd like to make thumbnails from a byte[] image that came from a Stream. I have two options, DecodePixelWidth or ScaleTransform. My Questions: Which one is faster? Which is the more appropriate way? What does each of them do? Which one uses less memory/CPU? First: I prefer this method. It...

How to decode XML entities in SQL?

sql,sql-server,decode
How can I convert/decode a text in &#1594;&#1604;&#1575;&#1605;&#1581;&#1587;&#1610;&#1606; format to normal text? I'm using SQL server 2012. I just want to update all of them to normal text. ...

How to use decode jquery script

jquery,base64,decode
I need base64 decode script. I have for example: var windowWidth = $( window ).width(); var windowHeight = $( window ).height(); var documentWidth = $( document ).width(); var documentHeight = $( document ).height(); I use this online plugin: Base64 Decode Encode Plugin and result from this plugin is:...

Decoding a JSON object and echo a specific value?

php,json,decode
I have a PHP page where I reference a JSON object that looks like this: { "body": { "zip": "02110", "stores": [ { "storeEmail": "[email protected]", "storeName": "Name", "city": "City", "Availability": { "123": { "Quote": "daily", "Display": "available", } }, }, Each JSON object contains multiple "stores", above is one example....

OpenERP 7 : How can I open a decoded file as a CSV file?

python,csv,decode,openerp-7
I have a module which asks the user to give a csv file, with the binary field. So once the module has it, I decode it and write the result in a Temporary File, but then I can't open it as a CSV file : I will get the error...

C# Decode Cyrillic to ASCII

c#,decode,asciiencoding
I have a very nice function which encodes ASCII to russian charachters, however I need it also the other way around from russian to ASCII. The function I have is: public string DecodeEncodedNonAsciiCharacters(string value) { return Regex.Replace( value, @"\\u(?<Value>[a-zA-Z0-9]{4})", m => { return ((char)int.Parse(m.Groups["Value"].Value, NumberStyles.HexNumber)).ToString(); }); } I cant find...

Dictionary from a string skips new line character

c#,string,dictionary,decode,encode
EDIT (C#) I have an dictionary coded as string and I want to retrieve it back. The problem is that, I use regex and I get dictionary without '\n' key. Here is code preview for console application: dictionaries example If you can see, the first and second dictionaries doesn't match....

python proper way to decode raw udp packet

python,decode,packet
I'm making a script to get Valve's server information (players online, map, etc) the packet I get when I request for information is this: '\xff\xff\xff\xffI\x11Stargate Central CAP SBEP\x00sb_wuwgalaxy_fix\x00garrysmod\x00Spacebuild\x00\xa0\x0f\n\x0c\x00dw\x00\x0114.09.08\x00\xb1\x87i\x06\xb4g\x17.\[email protected]\x01gm:spacebuild3\x00\xa0\x0f\x00\x00\x00\x00\x00\x00' This may help you to see what I'm trying to do https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO The problem is, I don't know how to decode this...

Python UTF-8 Latin-1 displays wrong character

python,utf-8,decode,encode,latin1
I'm writing a very small script that can convert latin-1 characters into unicode (I'm a complete beginner in Python). I tried a method like this: def latin1_to_unicode(character): uni = character.decode('latin-1').encode("utf-8") retutn uni It works fine for characters that are not specific to the latin-1 set, but if I try the...