Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I would like to know how to convert a linear String (on mysql) into gson JsonArray.
So to resume:
"{\"name\":\"john\",\"age\":22,\"class\":\"mca\"}"
-> {"name":"john","age":22,"class":"mca"} (As JsonArray using gson)
{"name":"john","age":22,"class":"mca"}
Thank you very much <3
StringEscapeUtils.unescapeJson
This should work.
import com.google.gson.*; JsonParser parser = new JsonParser(); JsonElement tradeElement = parser.parse(yourString); JsonArray jsonArray = tradeElement.getAsJsonArray(); System.out.println(jsonArray);
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
StringEscapeUtils.unescapeJsonmethod. See: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING while using Gson library and How to transfer escaped JSON lines to list of beans related questions.