Forum Post: RE: merging json objects

Status
Not open for further replies.
H

Håvard Danielsen

Guest
I'm trying to merge two json objects together. The code below seems to work, but I was wondering if there is any other (faste r, more efficient) way. I believe this is the only way to merge Json nodes in ABL. You should probably wrap your merge with a Has check instead of using Add with no-error and also check for NULLs. do lv_i = 1 to extent(lv_name): /** add to the target object using the appropriate getter on the source object */ if not oTarget:Has(lv_name[lv_i]) then do: case oSource:GetType(lv_name[lv_i]): when JsonDataType:ARRAY then oTarget:Add(lv_name[lv_i],oSource:GetJsonArray(lv_name[lv_i])). when JsonDataType:BOOLEAN then oTarget:Add(lv_name[lv_i],oSource:GetLogical(lv_name[lv_i])). when JsonDataType:NUMBER then oTarget:Add(lv_name[lv_i],oSource:GetDecimal(lv_name[lv_i])). when JsonDataType:OBJECT then oTarget:Add(lv_name[lv_i],oSource:GetJsonObject(lv_name[lv_i])). when JsonDataType:STRING then oTarget:Add(lv_name[lv_i],oSource:GetCharacter(lv_name[lv_i])). when JsonDataType:NULL then oTarget:AddNull(lv_name[lv_i]). end case. end. end. yp.

Continue reading...
 
Status
Not open for further replies.
Top