Unit 'fpJsonValue' Package
[Overview][Procedures and functions][Index] [#fcl]

JSONToValue

Converts JSON data to a TValue record

Declaration

Source position: fpjsonvalue.pp line 32

function JSONToValue(

  aData: TJSONData;

  aType: TRttiType

):TValue;

Arguments

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

ValueToJSON

  

Converts a TValue to a JSON data structure


Documentation generated on: Jan 27 2026