How to get value from this json object - json

Here the json data. [1,"GarageC","NUR841",1611241200]
how do i get the GarageC out from json.decode?

This is array you can retrieve value from array by index basis like array_name[index]

Related

How to get the length of object within a JSON?

How do I get the length of an object stored within a JSON?
Object.keys can be used to return an array of all the keys of the object and then you get the length of that array - that's the number that you are looking for.
console.log( Object.keys({"0":89,"1":54,"2":34,"3":67,"4":131}).length );

How to extract value from a nested json array?

i have a json object which contains json data with a key. now i want to extract value from that json object like name, address etc and store them to variables.
controller
json_arr = new JSONArray(j_str);
int count = json_arr.length();
json_o.put("user", json_arr);
j_str contains following data
[{"Bollywood":[{"actor":[{"name":"AA","gender":"Male"},{"name":"BB","gender":"Male"}]}]},{"Hollywood":[{"actor":[{"name":"CC","gender":"Male"},{"name":"DD","gender":"Male"}]}]}]
now it is converted to json object -- json_o ,, putting a key --- "user". now how can get a specific data such as 2nd actor name from hollywood. (i.e value DD). after then store that to a string.
Short answer: Use Jackson to map the json string to a java object, and then extract that value as a variable.
Here is a quick guide on doing this with jackson: http://www.mkyong.com/java/how-to-convert-java-object-to-from-json-jackson/

Extract key/value pairs from $http response in angularjs

I have a rest call to a server which returns me something that looks like this:
response.searchResult = ["{\"key1\":\"value1\",
\"key2\":\"value2\",
\"key3\":\"value3\"}"]
How can I extract all key-value pairs into a json array? Or at the very least, how can I search for the value associated with a specific key, lets say "key2" from the example?
Just run json.parse on the array entry:
response.searchResult = ["{\"key1\":\"value1\",\"key2\":\"value2\",\"key3\":\"value3\"}"];
var jsonResult = JSON.parse(response.searchResult[0]);
console.log(jsonResult);

How to convert the JSON array into dictionary of key value pairs

I have a dynamic Json. from that json I have converted that json into
var mainjson = (IDictionary)SimpleJson.DeserializeObject(received);
dictionary of key value pairs
Now I get json Array from
var secjson = mainjson["feelingLucky"];
now the secjson is a Json Array now I want to convert it into Dictionary of key Value Pairs. Is it possible in wp8 to convert json Array into Dictionary??
You already deserialized your received json into IDictionary. So now mainjson["feelingLucky"] should be having key value pair if it was correctly formatted in Json object "received".
Can you post the sample structure of your "received".

Getting data from JSON Array

my JSON response is as given below
JSON response is
{"code":201,"message":[["TEST Action","NA","30-11--2011"],["TEST Action 2","NA","30-11--2011"]]}.
i want to take the data correspond to 'message'.i used JSON Array.and got response as
JSON array response is
[["TEST Action","NA","30-11--2011"],["TEST Action 2","NA","30-11--2011"]].
Now how can i access each array in that?
You should expand on what you have done, what language you are using, etc. Normally, you should be able to index into the array with the standard notation. In python for example you can do something along the lines of json_data["message"][0] to access the first array and json_data["message"][1] to access the second.
something like :
var d = JSON.parse('{"code":201,"message":[["TEST Action","NA","30-11--2011"],["TEST Action 2","NA","30-11--2011"]]}')
and then you can access each array in message part as :
d.message.forEach(function(obj) { console.log(obj); });