0

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?

2
  • Using one of the numerous JSON parsers in Java? Commented Feb 28, 2014 at 8:25
  • 1
    my suggestion is the famous jackson Commented Feb 28, 2014 at 8:30

2 Answers 2

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);
Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. I tried to your method. but Error occurred that "The constructor JSONArray(String) is undefined".
Are you using the library which I linked in my answer? [code.google.com/p/org-json-java/downloads/…
I succeeded that convert to JsonArray from String of JsonArray format. And I try to convert that JsonObject from JsonObject in JsonArray. Could you explain about this method?
No you cannot convert jsonarray to jsonobject as contents with in {} 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.
0

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

maybe tags are confusing but OP does ask How you can convert JsonArray from String of JsonArray format in Java?
maybe he doesn't know the difference? Anyway it's confusing!
Thank you. but I have been called server form Data in JavaScript for client. This data is value of String.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.