Home

Awesome

JSON library for Delphi

This is a small and clean library for associative arrays with Boolean / Integer / Float / WideString values. Allows import (export) from (to) JSON text. Extensive error-checking.

Some open-source projects I would like to give credit:

The library was built for the ease of use and clean understandable code - performance was not a first priority so I have not made any benchmarking.

Features

Types of node values

NameDescription
jsNullThe NULL value
jsBoolNode value is Boolean
jsIntNode value is Integer
jsFloatNode value is Floating-point
jsStringNode value is String
jsArrayNode is an array - has children

Iterators

Parsing

function ParseJSON(JSON_str: PAnsiChar): TJSONbase;

Properties

NameTypeDescription
AssocBooleanWhether all keys are Numeric or at least one key is String
ParentTJSONbaseWhere the given node belongs to
FirstChildTJSONbaseChilds are organized as a double-linked list
LastChildTJSONbaseChilds are organized as a double-linked list
NextTJSONbaseNext sibling (by the order of creation)
PrevTJSONbasePrevious sibling (by the order of creation)
SelfTypeTJSONtypeType of data in the current node
ValueVariantValue of the current node
CountIntegerNumber of children if the node is non-scalar
NameWideStringThe String key of the current node if this is an associative array
IDIntegerThe Numeric key of the current node if this is non-associative array
Child[Index: Integer]TJSONbaseUsed to access the children of non-associative arrays
Field[Key: WideString]TJSONbaseUsed to access the children of associatve arrays
JsonTextAnsiStringStringification of the current node as JSON text

Methods

NameParametersReturnsDescription
ClearRemove all children
DeleteIdx: IntegerDelete a child from non-associative array and free the object
DeleteKey: WideStringDelete a child from associative array and free the object
RemoveIdx: IntegerTJSONbaseRemovee a child from non-associative array and return the object
RemoveKey: WideStringTJSONbaseRemove a child from associative array and return the object
ForEachIterator: TJSONEnum<br>UserData: PointerIterates over the children of non-associative array
ForEachIterator: TJSONEnumObj<br>UserData: PointerIterates over the children of associative array
AddB: BooleanTJSONbaseAppends a new Boolean child to the node (making it an array if not already, returns the new child)
AddI: Int64TJSONbaseAppends a new Integer child to the node (making it an array if not already, returns the new child)
AddD: DoubleTJSONbaseAppends a new Floating-point child to the node (making it an array if not already, returns the new child)
AddS: WideStringTJSONbaseAppends a new String child to the node (making it an array if not already, returns the new child)
AddA: TJSONbaseAppends an existing array as a child to the node (making it an array if not already
AddKey: WideString<br>B: BooleanTJSONbaseAppends a new Boolean child to the node (making it an array if not already, returns the new child)
AddKey: WideString<br>I: Int64TJSONbaseAppends a new Integer child to the node (making it an array if not already, returns the new child)
AddKey: WideString<br>D: DoubleTJSONbaseAppends a new Floating-point child to the node (making it an array if not already, returns the new child)
AddKey: WideString<br>S: WideStringTJSONbaseAppends a new String child to the node (making it an array if not already, returns the new child)
AddKey: WideString<br>A: TJSONbaseAppends an existing array as a child to the node (making it an array if not already

Possible errors