2

I wish to query json result data to be used in Razor view and would like to know how to search by a specific id and capture data for a specific node:

Here is an example(just a part) of my json:

{
   "maxPages":1,
   "data":[
      {
         "id":"123",
         "perfomanceData":[
            {
               "platform":{
                  "name":"Test0",
                  "id":0
               }, 
         ],
     {
         "id":"124",
         "perfomanceData":[
            {
               "platform":{
                  "name":"Test1",
                  "id":0
               }, 
         ],
     {
         "id":"125",
         "perfomanceData":[
            {
               "platform":{
                  "name":"Test2",
                  "id":0
               }, 
         ],

I wish to search by an ID example 125 and retrieve just this section

perfomanceData":[
                {
                   "platform":{
                      "name":"Test2",
                      "id":0
                   }, 
             ]

How can I use JavaScript to do the above?

Milligran
  • 3,031
  • 9
  • 44
  • 56
  • 2
    Please note that the problem has nothing to do with JSON but rather with how to process JS arrays and objects. *How* you got the data is irrelevant (unless you really want to process raw JSON data in JS, i.e. apply string processing, which is probably more complicated than parsing the JSON). – Felix Kling Sep 09 '13 at 20:10
  • look into taffyDB, you can turn your json into taffy with one line, then use taffy's query features. if you need something simpler, http://danml.com/js/oquery.js works like oQuery( obj, "[id=125]")... – dandavis Sep 09 '13 at 20:40
  • Your json is malformed. – acdcjunior Sep 09 '13 at 21:36

0 Answers0