I have an unusual qustion which looks as the following:
Question 1: How can i split a String the right way so that i get the json-File Entries separated from one another.
Or Question: How do i convert a String to JSONArray.
The JSON:
[
{
"id":"123483",
"content":{
"amount":"460",
"price":"2.15",
"name":"Post-it Block weiß",
"weight":"0.3",
"category":"Notizzettel"
}
},
{
"id":"501993",
"content":{
"amount":"83",
"price":"25.0",
"name":"Trennstreifen 5x 100 bunt",
"weight":"0.024",
"category":"Register"
}
}
]
What i tried: // content succesfully encapsulates all the json content.
Path path = Paths.get("src/com/json/inventory.json");
String content = new String(Files.readAllBytes(path), Charset.defaultCharset());
JSONArray jsonArray = new JSONArray();
JSONObject jsnobject = new JSONObject(content);
jsonArray.put(jsnobject);
The Errors with JSONArray: Errors