Best way to store a JSON

1

Hello, I get a json on this template from a request

{  
   "alunos":[  
      {  
         "ID":"1",
         "Nome":"Pedro",
      },
      {  
         "ID":"2",
         "Nome":"Lucas",
      },
      {  
         "ID":"3",
         "Nome":"Joana",
      }
   ]
}

I would like a good example of how to store it in a local variable, for later use, would array be a good choice?

    
asked by anonymous 08.11.2017 / 20:07

1 answer

0

The best way would be to convert to a javascript object.

Most browsers support JSON.parse (), which is defined in the ECMA-262 5th edition (the specification on which JavaScript is based):

var json = '{"teste":1,"teste2":true}',
var obj = JSON.parse(json);

Here are some references worth checking out to better understand how json parse works in javascript:

link

link

link

    
09.11.2017 / 18:05