Skip to main content

ValueType

property ValueType: TJSONValueType read;

Example

procedure ScriptEvent(var Value: variant);
var
Document: TJSONObject;
Item: TJSONValue;
begin
Document := TJSONObject.CreateFromString('{"status":"ready"}');
try
Item := Document.FindValue('status');
Value := Item.ValueType = jsString;
finally
Document.Free;
end;
end;

Usage

ValueType reports the immutable JSON kind assigned from the runtime class during Velox value construction.

Additional Technical Info

ValueType is assigned once by native Create from the actual runtime class and has no writer. The values are:

ValueNative class family
jsStringTJSONString
jsNumberTJSONInteger and TJSONDouble through hidden TJSONNumber
jsBooleanTJSONBoolean
jsArrayTJSONArray
jsObjectTJSONObject
jsNullTJSONNull

The kind is independent of IsNull. A null-marked TJSONString remains jsString, not jsNull; only a real TJSONNull reports jsNull. Clear, assignment, parsing into an existing matching container and CopyFrom do not change the receiver's kind. Use both properties when semantic null and physical representation matter.

The tag is a broad JSON kind, not an exact Delphi class check. Both integer and Double nodes report jsNumber, while their precision and conversion behavior differ. Checked AsArray, AsObject and AsText still validate the actual object class.

The numeric importer defect creates an exception to reliable script construction: hidden TJSONNumber is parented beneath TObject, so direct typed numeric construction can skip the native classifier and leave the zero-initialized ordinal jsString. Parser- and helper-created numeric nodes run the native constructor and report jsNumber. A typed numeric script expression also lacks this inherited property; inspect a generic TJSONValue obtained from its parent.

Reading is constant-time, side-effect-free and unaffected by name or ownership.

External references

Created 2026-07-15