Объединение (Concat) нескольких объектов JSONObject в JavaJAVA

Программисты JAVA общаются здесь
Anonymous
Объединение (Concat) нескольких объектов JSONObject в Java

Сообщение Anonymous »


I am consuming some JSON from two different sources, I end up with two JSONObjects and I'd like to combine them into one.

Data:

"Object1": { "Stringkey":"StringVal", "ArrayKey": [Data0, Data1] } "Object2": { "Stringkey":"StringVal", "Stringkey":"StringVal", "Stringkey":"StringVal", } Code, using http://json.org/java/ library:

// jso1 and jso2 are some JSONObjects already instantiated JSONObject Obj1 = (JSONObject) jso.get("Object1"); JSONObject Obj2 = (JSONObject) jso.get("Object2"); So in this situation I'd like to combine Obj1 and Obj2, either to make a totally new JSONObject or concat one to the other. Any ideas besides pulling them all apart and individually adding in by puts?


Источник: https://stackoverflow.com/questions/240 ... ts-in-java

Вернуться в «JAVA»