0

I have an object with a single member 'jsonMember' which contains an array containing objects as follows:

jsonMember: [{"name":"GGLV-L014054","manufacturer.name":"TOSHIBA"},
{"name":"GGLV-W014329","manufacturer.name":"FUJITSU"}]

I am able to return 'name' but when making the same call for 'manufacturer.name' I get undefined.

I have tried a number of variations without any luck and I would really appreciate a helpful pair of eyes.

var parser = new JSONParser();
var parsed = parser.parse(jsonString);
    for (i = 0; i < parsed.length; i++) {
        var name = parsed[i].name; //Works fine
        var manufacturer = parsed[i].manufacturer.name; //returns undefined
1
  • 3
    parsed[i]['manufacturer.name'] Commented Sep 6, 2015 at 3:40

2 Answers 2

1

change

var manufacturer = parsed[i].manufacturer.name;

to

 var manufacturer = parsed[i]["manufacturer.name"];
Sign up to request clarification or add additional context in comments.

Comments

0

You have to properly formalize each internal object, you can't just use the . like that.

Try this

jsonMember: [{"name":"GGLV-L014054","manufacturer":{"name" : "TOSHIBA"}},  {"name":"GGLV-W014329","manufacturer": {"name" : "FUJITSU"} }]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.