Skip to content

EF.JSON

Support for reading and writing data in JSON format.

<seealso href="http://www.json.org/"> JSON web site </seealso>

Routines

pascal
function PairsToJSON(const APairs: TEFPairs;

Builds a JSON representation of the pairs.

Example: Param1='Foo', Param2=20

Result: '["Param1", "Foo"], ["Param2", "20"]'

Set AReversed to True to switch keys and values.

pascal
function TriplesToJSON(const ATriples: TEFTriples): string;

Builds a JSON representation of the triples.

Example: A B C, One Two Three

Result: '["A", "B", "C"], ["One", "Two", '"Three"]'

pascal
function DataSetToJSON(const ADBConnection: TEFDBConnection;

Builds a JSON representation of a dataset's fields values. Creates the dataset by executing the specified command text against the specified DB connection. Each record is enclosed in []s and each value is double-quoted.

<para><c>'["IT", "ITALY"], ["UK", "UNITED KINGDOM"]'</c></para>
pascal
function DataSetToJSON(const ADataSet: TDataSet;

Builds a JSON representation of a dataset's fields values. Each record is enclosed in []s and each value is double-quoted.

<para><c>'["IT", "ITALY"], ["UK", "UNITED KINGDOM"]'</c></para>
pascal
function QuoteJSONStr(const AString: string): string;

Wraps the string in double quotes, escaping any embedded double quotes.

pascal
function QuoteJSONValue(const AString: string): string;

Escapes special characters and wraps the string in double quotes, producing a valid JSON string value.

pascal
function JSONNullToEmptyStr(const AJSONValue: string): string;

Returns '' when AJSONValue is the JSON literal 'null', otherwise returns AJSONValue unchanged.

pascal
function JSONEscape(const AString: string): string;

Escapes control characters in the JSON string.

pascal
procedure LoadJSONObjectInTree(const AJSONObject: TJSONObject;

Adds to ATree all pairs in AJSONObject, recursively. All values are treated as strings. Arrays are not supported. If a JSON array is found, an exception is raised.

Released under Apache License, Version 2.0.