0

I have the following JSON object:

I'm not sure how to parse this into usable variables in Javascript.

One thing that makes this tricky is that the names will not always be the same.

materialid could be named othernameid.

title could be named somethingelsetitle.

I'd need to be able to dynamically know each name and it's value.

Thanks!

{  
   "3":[  
      {  
         "materialid":3,
         "title":"New Titlted Stuff",
         "description":"Description of Stuff",
         "datecreated":"05/09/2018",
         "keywords":"Keywords about stuff",
         "material":"7_html_logo.png"
      }
   ],
   "4":[  
      {  
         "materialid":4,
         "title":"ABC title",
         "description":"ABC desc",
         "datecreated":"05/23/2018",
         "keywords":"ABC Keywords",
         "material":"8_angular_logo.png"
      }
   ],
   "5":[  
      {  
         "materialid":5,
         "title":"4th try",
         "description":"describe 4th thing",
         "datecreated":"05/14/2018",
         "keywords":"4th thing keywords",
         "material":null
      }
   ]
}
  • Could you please elaborate on what you mean by 'parsing into usable variables'? It'd be helpful if you showed an example of what you're expecting the result to be (and even more helpful if you show some code you've already tried!) – Joe Clay May 16 '18 at 15:33
  • It's either a JSON string, in which case you parse it with `JSON.parse()` or it's a javascript object in which case it's already in a variable. You should tells us specifically what you mean by `usable`. For example, it's usage now with `obj[3][0]['title']` – Mark May 16 '18 at 15:33
  • 1
    Please add a hard-coded example of the usable variables you expect to get from your above sample data. – Nope May 16 '18 at 15:35

0 Answers0