Danielh112
Danielh112

Reputation: 15

Convert String of Json object lists to list of JSON objects

After making a HTTP get request i'm returned with a list of JSON objects, is there any way in which I can convert this String into a list of JSON objects??

Example response:

[{"name":"test","description":"","dbType":"sql server"}, 
{"name":"test1","description":"","dbType":"sql server"}, 
{"name":"test2","description":"","dbType":"sql oracle"}]

Thank you in advance for any help!

Upvotes: 0

Views: 1327

Answers (1)

Rahul Rabhadiya
Rahul Rabhadiya

Reputation: 430

Simple json api can do what you want for e.g

String stringToParse  = "[{'name':'test','description':'','dbType':'sql'}, "
            + "{'name':'test1','description':'','dbType':'sql server'},"
            + "{'name':'test2','description':'','dbType':'sql oracle'}]";


JSONParser parser = new JSONParser();
JSONArray json = (JSONArray) parser.parse(stringToParse);

You can also look into Jackson json api.

Upvotes: 1

Related Questions