Creating JSON Arrays and JSON Objects

The BDL JSON API provides many functions to create and receive JSON arrays and JSON objects.

JsonParse

This function creates a JSON array or a JSON object from a string value. It returns the handle to the JSON array or the JSON object.

When the JSON array or the JSON object is not needed any longer, it is important to manually delete it from the memory with the function JsonFree.

dcltrans 
	transaction TMain 
	var 
		jsonArray  : number; 
		jsonObject : number; 
	begin  
		jsonArray := JsonParse(“[ \“StringValue\”, 10, 20.13, true, null ]”);
		jsonObject := JsonParse(“{ \”Id\”: 1, \”Name\” : \“New Object\” }”);

		... 

		JsonFree(jsonArray); 
		JsonFree(jsonObject);
	end TMain;

JsonObjectCreate, JsonArrayCreate

This function creates an empty JSON object or an empty JSON array. It returns the handle to the JSON object or the JSON array.

When the JSON object or the JSON array is not needed any longer, it is important to manually delete it from the memory with the function JsonFree.

dcltrans 
	transaction TMain 
	var 
		jsonObject : number; 
		jsonArray : number;
	begin  
		jsonObject := JsonObjectCreate;
		jsonArray:= JsonArrayCreate;

		... 

		JsonFree(jsonObject);
		JsonFree(jsonArray);
	end TMain;