简体   繁体   中英

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?

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);

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM