ValueToJSON¶
Converts a TValue to a JSON data structure
Declaration¶
Source position: fpjsonvalue.pp line 31
function ValueToJSON(const aValue: TValue; aType: TRttiType) : TJSONData;
Arguments¶
| Name | Description |
|---|---|
| aValue | The TValue record to convert to JSON |
| aType | The RTTI type information for the value being converted |
Function result¶
The JSON data structure representing the converted value
Description¶
ValueToJSON converts a TValue record to its corresponding JSON representation using the provided RTTI type information. The function supports conversion of strings (AnsiString, UnicodeString, WideString, ShortString), integers (Integer, Int64, QWord), booleans, and dynamic arrays. For dynamic arrays, the function recursively converts each element using the array's element type information. If an error occurs during conversion, any partially created JSON structure is cleaned up before re-raising the exception.
Errors¶
May raise an exception if the conversion fails or if an unsupported type is encountered.
See also¶
| Name | Description |
|---|---|
| JSONToValue | Converts JSON data to a TValue record |