TTMSMCPValueHelper.FromJSON Method
Converts an incoming JSON argument into a typed value according to the declared property type. The returned value holds a native type for scalars and arrays (for example
Integer,Double,Boolean,TDateTimeor a dynamic array), while object and raw JSON kinds keep a reference to the original JSON value.
API unit family: TMS.MCP.Helpers
Declaring type: TTMSMCPValueHelper
Syntax
class function FromJSON(const JsonValue: TJSONValue; const ExpectedType: TTMSMCPToolPropertyType): TValue; static;
Parameters
| Name | Description |
|---|---|
JsonValue |
The JSON value taken from the call parameters. Ownership stays with the caller; object and raw JSON kinds are referenced, not copied. |
ExpectedType |
The declared type of the property the value belongs to; it selects the conversion that is applied. |
Returns
The converted value.
Exceptions
| Exception | Description |
|---|---|
Exception |
Raised when the JSON value does not match the expected type, for example a non-numeric value for an integer property or a non-array value for an array property. |