user3363859
user3363859

Reputation: 3

How you can convert JsonArray from String of JsonArray format in Java?

Now, I try to link that fullcalendar in jQuery UI and Database(Oracle 10g). But, a problem has occurred.

I want to parse that JsonArray from String of JsonArray format.

ex) String of JsonArray format

-> String jsonArrayStr="[{test1:'test',test2:2,test3:'test3'},
                         {test1:'test',test2:2,test3:'test3'}, 
                         {test1:'test',test2:2,test3:'test3'}]";

String of JsonArray format->JsonArray

->JSONArray jsonArray = **(?)**

How you can convert JsonArray from String of JsonArray format in Java?

Upvotes: 0

Views: 5456

Answers (2)

ReeCube
ReeCube

Reputation: 2607

You are confusing me with your tags: "java" and "jquery", did you mean "JavaScript"? Because Java has no relation with jQuery....

If you mean JavaScript, this may be your solution:

var jsonArrayStr = "[{test1:'test',test2:2,test3:'test3'},{test1:'test',test2:2,test3:'test3'}, {test1:'test',test2:2,test3:'test3'}]";
var jsonArray = JSON.parse( jsonArrayStr );

If you mean really Java, try the following code:

JSONArray jsonArray = new JSONArray(jsonArrayStr);

Dependencies:

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

Upvotes: 0

Vinay
Vinay

Reputation: 6881

like this using this library

String jsonArrayStr="[{test1:'test',test2:2,test3:'test3'},{test1:'test',test2:2,test3:'test3'}, {test1:'test',test2:2,test3:'test3'}]";
JSONArray jrr = new JSONArray(jsonArrayStr);

Upvotes: 2

Related Questions