@Test
public void demo93() throws Exception {
String str = "[\"a\", \"b\", \"c\"]";
//Generate json arrays
JSONArray createArray = new JSONArray();
createArray.put("a");
createArray.put("b");
createArray.put("c");
System.out.println("createJSONArray: " + createArray);
//Parsing json arrays
JSONArray parseArray = new JSONArray(str);
System.out.println("parseJSONArray: " + parseArray);
for(int i = 0; i < parseArray.length(); i++) {
System.out.print(parseArray.get(i) + " ");
}
}
Output:
Read More:
- [Solved] TypeError: Converting circular structure to JSON – JSON.stringify
- [Solved] JSON.parse() Error: Unexpected end of JSON input
- [Solved] VS Code Error: Vetur can‘t find ‘tsconfig.json‘ or ‘jsconfig.json‘
- How to Solve JS error: Unexpected end of JSON input,Unexpected token u in JSON at position 0
- Json.parse: All Error & How to Solve Them
- Such a simple serialization system.text.json.serialization also reports an error?
- ERROR Error: [copy-webpack-plugin] patterns must be an array
- Using for in loop complex data types (object and array) in ES6
- [Solved] ajax Error: Uncaught SyntaxError: Unexpected end of JSON input
- [Solved] Warning: To load an ES module, set “type“: “module“ in the package.json or use the .mjs extension
- [Solved] Prittier format code error: JSON Error in…
- [Solved] Error: Cannot find module ‘vue-template-compiler/package.json‘ Require stack:
- The vue3 project Error: Cannot find module’vue-loader-v16/package.json’
- Error in created hook: “SyntaxError: Unexpected token u in JSON at position 0
- How to Solve Converting circular structure to JSON‘ Error
- [Solved] ERROR Error: Cannot find module ‘vue-loader-v16/package.json‘
- [Solved] Error in created hook: “SyntaxError: Unexpected token o in JSON at position 1“
- [Solved] electron Package and Startup Error: Error: ENOENT: no such file or directory, open ‘xxx/manifest.json‘‘
- package.json Scripts configuration environment variable distinguishes development environment from production environment
- [Solved] it only responds to error and does not enter success after AJAX is successfully processed