Come posso creare un oggetto JSON come il seguente, in Java usando JSONObject?Come creare JsonArray corretto in Java usando JSONObject
{
"employees": [
{"firstName": "John", "lastName": "Doe"},
{"firstName": "Anna", "lastName": "Smith"},
{"firstName": "Peter", "lastName": "Jones"}
],
"manager": [
{"firstName": "John", "lastName": "Doe"},
{"firstName": "Anna", "lastName": "Smith"},
{"firstName": "Peter", "lastName": "Jones"}
]
}
Ho trovato un sacco di esempi, ma non la mia esatta stringa JSONArray.
forse anche avvolgere in try/catch? (o il metodo deve avere una dichiarazione di tiri) – Lukas1
JSONArray non ha un metodo put. – Jim
usa add invece di put – CleanX