Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Appending JSON Array in PLSQL

User_CI7SYNov 11 2021

Hi Team, My final json_object named as final_o has extra array created because of append statement in the end and it looks like this: see those two square brackets. I want to remove them
{"distributors":[[{"dipid":"VISTA|032030","Distance":0,"Participation_score":0,"DIST_ID":null,"url":null,"quantityOnHand":0,"quantityOnHandUOM":"0","date_score":0,"dist_score":20,"totalQuantityOnHand":0,"pickShipFlag":null,"location_score":0,"loyalty_score":0,"rank":20},{"dipid":"VISTA|032030S","Distance":0,"Participation_score":0,"DIST_ID":null,"url":null,"quantityOnHand":0,"quantityOnHandUOM":"0","date_score":0,"dist_score":20,"totalQuantityOnHand":0,"pickShipFlag":null,"location_score":0,"loyalty_score":0,"rank":20},{"dipid":"VISTA|032030P","Distance":0,"Participation_score":0,"DIST_ID":null,"url":null,"quantityOnHand":0,"quantityOnHandUOM":"0","date_score":0,"dist_score":20,"totalQuantityOnHand":0,"pickShipFlag":null,"location_score":0,"loyalty_score":0,"rank":20}]]}
\
Code : I am not sharing complete code- it is big one.
IF final_p.get_size> 1 THEN
final_p_js_1 := json_object_t.parse(SortJsonArray(final_p_js.to_clob));
final_jsonarr_p := final_p_js_1.get_array('distributors');
else final_jsonarr_p := final_p_js.get_array('distributors');
END IF;

IF final_n.get_size> 1 THEN
final_n_js_1 := json_object_t.parse(SortJsonArray_NP(final_n_js.to_clob));
final_jsonarr_n := final_n_js_1.get_array('distributors');
else final_jsonarr_n := final_n_js.get_array('distributors');
END IF;

--Club non participating and participating distributors together
final_jsonarr_p.append(final_jsonarr_n);
final_o.put('distributors', final_jsonarr_p);
p_doc_out := final_o.to_clob;
end;

This post has been answered by padders on Nov 11 2021
Jump to Answer
Comments
Post Details
Added on Nov 11 2021
9 comments
2,448 views