1
I’m trying to create this object:
{
"schema": [
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:core:2.0:User",
"urn:ietf:params:scim:schemas:core:2.0:User"
],
"endereco": "Rua 0",
"nome": "Fulano",
"sobrenome": "de Tal"
}
but he leaves like this:
{
"{\"schema\":[\"urn:ietf:params:scim:schemas:core:2.0:User\",\"urn:ietf:params:scim:schemas:core:2.0:User\",\"urn:ietf:params:scim:schemas:core:2.0:User\"]}": {
"endereco": "Rua 0",
"nome": "Fulano",
"sobrenome": "de Tal"
}
}
my code
import org.json.simple.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;
public class Main {
public static void main(String[] args) throws JSONException {
JSONArray arr = new JSONArray();
JSONArray headers = new JSONArray();
JSONObject usuario = new JSONObject();
JSONObject head = new JSONObject();
JSONObject obj = new JSONObject();
usuario.put("nome", "Fulano");
usuario.put("sobrenome", "de Tal");
usuario.put("endereco", "Rua 0");
headers.put("urn:ietf:params:scim:schemas:core:2.0:User");
headers.put("urn:ietf:params:scim:schemas:core:2.0:User");
headers.put("urn:ietf:params:scim:schemas:core:2.0:User");
head.put("schema", headers);
obj.put(head, usuario);
System.out.println(obj);
}
}