JSON Parser  1.0
int json_generate_data_block ( list_object *  json_data,
JSON_value_types  json_data_type,
char **  json_text_buffer 
)

Using a JSON Object data tree, represented by a hierarchical D-List list_object structure, create a textural version of that JSON data presented and return a character array with that JSON data in it, in strict JSON Grammar format.

This function is essentially the reverse of json_parse_data_block(). It will walk through a D-List list_object structure containing the representation of a JSON data block, and create a textural version of that JSON data ready to be stored or transmitted over a network. This function, like all those in the JSON Parser Package, is fully thread safe and MP safe.

The input data must be in the correct form and conform to JSON grammar. Using the D-List hierarchical structure, there is very little that can be in error in that structure, so the generation function produces few error messages. The only real data problems that can occur are simple mistakes such as providing inaccurate JSON value types, or forgetting to provide a name for JSON Object members.

All textural strings that are created by the JSON Generator assume the bytes are either ASCII or UTF-8. It does not enforce any encoding standards. All string bytes are passed through without change, except those that are required by the relevant JSON standards to be escaped. This includes all control characters which are either escaped with a '\' or by hex code.

The JSON Generator will produce human readable JSON text, that is well structured and easy to read. If you take an existing JSON data block, parse it with the JSON Parser, and then run that output list_object through the JSON Generator, you will get back almost identical text with the exception of probably different formatting style, and most hex escapes in the original will be reproduced as UTF-8 instead.

Parameters
[in]json_dataA pointer to a root list_object for the JSON data structure the caller wishes to use to generate a JSON Text Data Block.
[in]json_data_typeThe type of data found at the top level, either JSON_object, JSON_array or JSON_value. This is the same kind of value type that would be returned if a call was made to the function parse_json_data_block()
[out]json_text_bufferA pointer to a location to write the pointer to the data block created by the JSON Generator.
Return values
0All JSON elements processed correctly, no syntax / grammar errors.
1JSON Object was empty, but processed correctly.
-1A JSON grammar or syntax error was found below the top level
-2An error was found in the JSON syntax at the top level
-3An argument error occurred
-4An error occurred during memory allocation, there is no output buffer available.