Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

Here is my JSON

[{"thumb_url":"tb-1370913834.jpg","event_id":"15","count":"44","event_tagline":"this is a tagline","event_name":"5th birthday","event_end":"1370919600","event_start":"1370876400"}]

I need it to get it into an array and be able to call the strings by their respective keys. Can anybody help me?

2 Answers

0 votes
by (13.1k points)

ArrayList<String> list = new ArrayList<String>();     

JSONArray jSonArray = (JSONArray)jsonObject; 

if (jSonArray != null) { 

   for (int i=0;i<jSonArray.length();i++){ 

    list.add(jSonArray.getString(i));

   } 

Want to learn Java? Check out the core Java certification from Intellipaat. 

0 votes
by (1.9k points)

To convert your JSON into an array and access the values by their keys in JavaScript, you can follow these steps:

Access the properties using their respective keys.

const jsonString = '[{"thumb_url":"tb-1370913834.jpg","event_id":"15","count":"44","event_tagline":"this is a tagline","event_name":"5th birthday","event_end":"1370919600","event_start":"1370876400"}]';

 const events = JSON.parse(jsonString);

 const event = events[0];

const thumb = event.thumb_url;

const name = event.event_name;

const tagline = event.event_tagline;

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
2 answers

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...