Get String from json with nested json object and nested json arrays with multiple json object, in Android
Date : March 29 2020, 07:55 AM
this one helps. I need to access as String all the single parameters contained in a complex Json. , I've not tried. But i guess it may work. JSONObject obj = new JSONObject(jsonString);
String id = obj.getString("id");
String error = obj.getString("error");
JSONObject result = obj.getJSONObject("result");
int nPeople = result.getInt("nPeople");
JSONArray people = result.getJSONArray("people");
for(int i = 0 ; i < people.length() ; i++){
JSONObject p = (JSONObject)people.get(i);
String namePeople = p.getString("namePeople");
...
}
|
Cannot access data in JSON array nested in JSON object using javascript
Date : March 29 2020, 07:55 AM
Hope that helps Try like this. JSON is string.Directly javascript's length property will not works.You have convert it to object first using JSON.parse(). json ='{"results":[{"eventName":"Rey","name":"Tar","dateOfShow":"2017-01-27T22:00:00","userGroupName":"Bit","eventHallName":"Grnn","imageSource":"test2.jpg"},{"eventName":"Gor","name":"Skum","dateOfShow":"2017-01-30T20:00:00","userGroupName":"Gaf","eventHallName":"Gai","imageSource":"test1.jpg"}]}';
res = JSON.parse(json)
alert(res.results.length);
|
JSON nested object access
Date : March 29 2020, 07:55 AM
To fix this issue I was in hurry for the task that i didn't realised.I used req.body.body.some.fname It wad the req body. I was foolish sorry
|
not able to access this JSON NESTED OBJECT
Tag : json , By : user149634
Date : March 29 2020, 07:55 AM
this will help You should use JSON.parse(), as follows: var json = '{"-LZn4rzsI3_0Mm0pcUZ2":{"email":"primedine@gmail.com","name":"Prime
Dine Restaurant","phone":9512556799},"-LZn4vGB7v0frlDywQ1x":
{"email":"mango@gmail.com","name":"@Mango","phone":7992556799},"-
LZn4xyGeo-yh6945mKC":{"email":"desitadka@gmail.com","name":"Global
Desi Tadka","phone":8872556799},"-LZn50DSU3JNw6hNcdzz":
{"email":"vishala@gmail.com","name":"VIshala","phone":9972556799}}';
var obj = JSON.parse(json);
//Use the object as desired, for example:
Object.keys(obj).forEach(e =>
console.log(`key = ${e} name = ${obj[e].name}`)
);
|
MYSQL JSON - how do I access nested JSON object that's indexed by numerical key?
Date : March 29 2020, 07:55 AM
Does that help I am trying to extract JSON document subtree that's indexed by numerical key. , Thnx for report, following case: $expr = mysql_xdevapi\Expression('$.tree."100"');
$result = $coll->find('$.pk=25')->fields($expr)->execute();
|