JSONToValue function
Converts JSON data to a TValue record
Declaration
function JSONToValue(aData: TJSONData; aType: TRttiType): TValueArguments
aData | The JSON data structure to convert to a TValue |
aType | The RTTI type information for the target value type |
Function result
The TValue record representing the converted JSON data
Description
JSONToValue converts a JSON data structure to its corresponding
TValue record using the provided RTTI type information.
The function supports conversion of JSON strings to Pascal strings (AnsiString, UnicodeString), JSON numbers to integers (Integer, Int64, QWord), JSON booleans to Pascal booleans, and JSON arrays to dynamic arrays.
For dynamic arrays, the function recursively converts each JSON array element using the array's element type information.
The function uses
TValue.Make and
TValue.FromArray to construct the appropriate TValue representation.Errors
May raise an exception if the conversion fails or if there is a type mismatch between the JSON data and the expected type.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
