I have a JSON of following format,
{
"A.B.C" : "a.b.c",
"C.D.E" : "c.d.e"
}
but I'm unable to parse this json in javascript.How can I get the value of "A.B.C"?
And I want to load this JSON in the content[] of Ember.ResourceController using load() in ember-rest.js
while loading this i got an error "Object in path A.B could not be found or was destroyed"
I have a JSON of following format,
{
"A.B.C" : "a.b.c",
"C.D.E" : "c.d.e"
}
but I'm unable to parse this json in javascript.How can I get the value of "A.B.C"?
And I want to load this JSON in the content[] of Ember.ResourceController using load() in ember-rest.js
while loading this i got an error "Object in path A.B could not be found or was destroyed"
Share Improve this question edited Nov 2, 2012 at 4:58 Bala asked Nov 1, 2012 at 12:19 BalaBala 677 bronze badges 3- "unable to parse" why? How you try? What error you get? – user447356 Commented Nov 1, 2012 at 12:24
- Read about Member Operators – epascarello Commented Nov 1, 2012 at 12:24
- Did you try any thing at all? – NewUser Commented Nov 1, 2012 at 12:31
4 Answers
Reset to default 7According to jsonlint, that JSON is valid, which means you can parse it regularly:
var obj = JSON.parse('{ "A.B.C" : "a.b.c", "C.D.E" : "c.d.e" }');
var test = obj["A.B.C"]; // "a.b.c"
http://jsfiddle/88vFv/
The trick is you need to use bracket notation instead of dot notation, since your property names contain dots.
Try this:
var json = { "A.B.C" : "a.b.c", "C.D.E" : "c.d.e" };
var value = json["A.B.C"];
DId you try this?
data = JSON.parse('{ "A.B.C" : "a.b.c", "C.D.E" : "c.d.e" }')
data["A.B.C"]
Just use JSON.parse
:
var values = JSON.parse('{ "A.B.C" : "a.b.c", "C.D.E" : "c.d.e" }');
var result = values['A.B.C'];