Skip to main content

jsObject

jsObject = 4

Example

function HasCustomer(Value: TJSONValue): Boolean;
begin
Result := (Value.ValueType = jsObject) and
Value.AsObject.Contains('customer');
end;

Usage

jsObject identifies an owned Velox JSONObject whose name lookup and compact serialisation have Velox-specific side effects and defects.

Additional Technical Info

jsObject is ordinal 4 of TJSONValueType. The base constructor assigns it to TJSONObject. Check it before TJSONValue.AsObject, which is a checked class cast.

Objects own their child values; delete, clear and destruction free them. Lookup is case-insensitive and returns the first matching name, while Add permits duplicate names. This differs from systems that require case-sensitive or unique member names. Preserve insertion order only when the downstream contract permits it; JSON consumers can handle duplicates differently.

Reading Values[Name] is mutating: a missing name causes the object to add and return a named TJSONNull. Use Contains before indexed lookup when a read must not create data. Arrays and objects always report non-null, including empty containers.

Serialization defects

The compiled compact AsString implementation returns only } for an empty object: it removes the opening brace as if it were a trailing comma. For nonempty objects it wraps property names in quotes but does not JSON-escape quotes, backslashes or control characters in those names. Duplicate members are all emitted. Child values also inherit numeric locale and string-escape limitations.

Do not use this serializer for an empty object or arbitrary external property names without validating/correcting the output. A standards-compliant serializer is safer for public interchange.

The example uses Contains specifically to avoid the missing-value mutation and was source-reviewed; no JSON parsing, serialization, ownership, runtime or image test ran.

Related Code Library entries

External references

Created 2026-07-15