results = {ArrayList@22831} size = 11
0 = {LinkedTreeMap@22840} size = 36
0 = {LinkedTreeMap$Node@22854} "id" -> "7.0"
1 = {LinkedTreeMap$Node@22855} "version" -> "0.0"
2 = {LinkedTreeMap$Node@22856} "family" -> " size = 9",
.
.
.
35 = "formattedValue"-> "[
{
"subCondition":"default",
"maxGuarantee":{
"amount":2500000,
"currencyCode":"USD"
},
"minGuarantee":{
"amount":30000,
"currencyCode":"USD"
},
"minLoanAmount":{
.
.
.
I need to add
"minGuaranteePerPerson":{
"amount":30000,
"currencyCode":"USD"
},
to add the bottom of that array i gave at the first. So, it will be in formattedValue. At the end, it will be like this:
35 = "formattedValue"-> "[
{
"subCondition":"default",
"maxGuarantee":{
"amount":2500000,
"currencyCode":"USD"
},
"minGuarantee":{
"amount":30000,
"currencyCode":"USD"
},
"minLoanAmount":{
...
},"minGuaranteePerPerson":{
"amount":30000,
"currencyCode":"USD"
},
I tried this:
final JsonObject json = (JsonObject) results.get(i).get("formattedValue").toString()
but it gave error of like Can't cast gson to my Object type
Probably because it is not JSONOBject, it is array.
results
is like this
ArrayList<LinkedTreeMap<String, Object>> results;
I need to first get that JSon, that to add my variable but i can not get.
Can not use objectmapper because there is no DTO or class. I need to do with add operations.
When i do
new JSONArray(results)
it shows:
[{"code":"KOBI","componentBases":[],"formattedValue":"[{\"subCondition\":\"default\",\"minGuaranteeRate\":\"15\",\"maxGuaranteeRate\":\"25\",\"maxGuaranteeAmount\":{\"amount\":2500000,\"currencyCode\":\"TRY\"},//and so on
when i do
new JSONArray(results).getJSONObject(0)
it shows only first one.
new JSONObject(results)
this shows empty false