How Do I Parse This JSON Data [on hold]

187
February 05, 2018, at 7:40 PM

I tried JSON.parse but didn't work. Please tell me how I can parse this data.

[
{
"value": { "top": 343,"left": 397,"width": 283,"height": 283} ,
"main": {"sm": 0.263,"sd": 5,"fs": 22,"gs": 15}
  }
]

My goal is reach the objects with obj.x like:

obj = JSON.parse(data);
$( "#dialog_title_span" ).text(obj.value.top + obj.value.left);

Edit: Json Corrected.

Answer 1

This is not a jSON. It is just an array of objects. You can traverse through loop. Like data[0].value.top gives you 343.

JSON is

Data is in name/value pairs, Data is separated by commas, Curly braces hold objects,

like:-

var value = '{ "name":"John", "age":30, "city":"New York"}'

This is a JSON. you can parse it using JSON.parse

a = JSON.parse(value)

Then you can acces name like:-

a.name

For more refernce you can study here

Rent Charter Buses Company
READ ALSO
On event in jquery [on hold]

On event in jquery [on hold]

I have 2 datatablesI want to add a row to another table and remove from the other table

179
Sticky foreground service fails to restart with a “process is bad” error

Sticky foreground service fails to restart with a “process is bad” error

I have a started foreground serviceI've taken care to return START_STICKY from onStartCommand

437
Converting a python program into Java [on hold]

Converting a python program into Java [on hold]

So I wrote this very basic code in python,I used repltit to write and test this

250
curl Command using spring rest template

curl Command using spring rest template

I am posting JSON originally via terminal, which looks like this

2137