0

I have a json file like this:

{
    id1: ["text1" , "content1" ],
    id2: ["text2" , "content2" ],
    id3: ["text3" , "content3" ]
}

var number =2;

How can I find property of json with id number equal to "number" and retrieve its 2 element "text2" and "content2".

Arbel
  • 30,599
  • 2
  • 28
  • 29
John Macl
  • 331
  • 2
  • 5
  • 12

1 Answers1

2

Do you mean something like this?

var number = 2;
console.log(json['id'+number]);

Its probably duplicate

Community
  • 1
  • 1
Nano
  • 1,398
  • 6
  • 20
  • 32