0

I have json serialized arraylist in java which i want to insert into another json object, how can i do this without having double quotes on my json string?

JSONSerializer serializer = new JSONSerializer();
String serializedList = serializer.serialize(myArrayList);

I want serializedList nested into my json object:

myJsonOutput = Json.createObjectBuilder()
                            .add("key1", "val1")
                                .add("key2", "val2")
                                .add("myArray", serializedList)
                            .build();

If i do it like this my serializedList will be inserted as a whole string?

Mac Luc
  • 971
  • 5
  • 14
  • 31
  • Why don't you want double quotes? The serializer will insert escapes appropriately. – Hot Licks Sep 17 '14 at 12:20
  • (If you want it inserted as normal JSON, you need to deserialize it and insert that, not the serialized string.) – Hot Licks Sep 17 '14 at 12:21
  • @HotLicks well my question is then: How do i insert my java ArrayList in my json object? Do i have to serialize it (with flexjson or gson) and then deserialize it into an object again? – Mac Luc Sep 17 '14 at 12:31
  • You insert it like you'd insert anything else. An ArrayList maps directly to a JSON "array". – Hot Licks Sep 17 '14 at 15:46

0 Answers0