util.JSONObject.remove() removes the specified element from the JSON object.
Syntax
CALL util.JSONObject.remove("key")
Parameters
key |
a key part of the element of the JSON object (= the key:value pair) |
Usage and examples
util.JSONObject.remove() takes the key of the element of the JSON object (= the key:value pair) as the parameter and deletes this element.
MAIN
DEFINE json_obj util.JSONObject
LET json_obj=util.JSONObject.create()
CALL json_obj.insert("address","5 Brando Street")
CALL json_obj.remove("address")
DISPLAY json_obj.get("address")
CALL fgl_getkey()
END MAIN
MAIN
DEFINE json_obj util.JSONObject
DEFINE js STRING
LET json_obj=util.JSONObject.create()
CALL json_obj.insert("id",8723)
CALL json_obj.insert("name","McMaclum")
CALL json_obj.insert("address","5 Brando Street")
CALL json_obj.insert("position","staff")
LET js= json_obj.toString()
DISPLAY util.JSON.format(js)
CALL json_obj.remove("address")
LET js= json_obj.toString()
DISPLAY util.JSON.format(js)
CALL fgl_getkey()
END MAIN
MAIN
DEFINE json_obj util.JSONObject
DEFINE cust_rec RECORD
cust_num INTEGER,
cust_name VARCHAR(30),
cust_address VARCHAR(30),
order_ids DYNAMIC ARRAY OF INTEGER
END RECORD
DEFINE js STRING
LET cust_rec.cust_num=345
LET cust_rec.cust_name="McMaclum"
LET cust_rec.cust_address="5 Brando Street"
LET cust_rec.order_ids[1] =4732
LET cust_rec.order_ids[2] =9834
LET json_obj= util.JSONObject.fromFGL(cust_rec)
LET js= json_obj.toString()
DISPLAY util.JSON.format(js)
CALL json_obj.remove("cust_address")
LET js= json_obj.toString()
DISPLAY util.JSON.format(js)
CALL fgl_getkey()
END MAIN