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?
-
Using one of the numerous JSON parsers in Java?Smutje– Smutje2014年02月28日 08:25:40 +00:00Commented Feb 28, 2014 at 8:25
-
1my suggestion is the famous jacksonD Blacksmith– D Blacksmith2014年02月28日 08:30:07 +00:00Commented Feb 28, 2014 at 8:30
2 Answers 2
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);
4 Comments
{} are jsonobject and [] and these are jsonarray you need to change the structure. the things are key and value pairs like {key : value } in jsonobject and and [val, val, val] in json array.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;
3 Comments
How you can convert JsonArray from String of JsonArray format in Java?