System.JSON.Builders.TJSONCollectionBuilder.TPairs.AddPairs
Delphi
function AddPairs(const APairs: array of const): TPairs; overload;
function AddPairs(const ABuilder: TJSONCollectionBuilder): TPairs; overload; inline;
function AddPairs(const AJSON: string): TPairs; overload; inline;
C++
HIDESBASE TJSONCollectionBuilder::TPairs* __fastcall AddPairs(const System::TVarRec *APairs, const int APairs_High)/* overload */;
HIDESBASE TJSONCollectionBuilder::TPairs* __fastcall AddPairs(TJSONCollectionBuilder* const ABuilder)/* overload */;
HIDESBASE TJSONCollectionBuilder::TPairs* __fastcall AddPairs(const System::UnicodeString AJSON)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.JSON.Builders.pas System.JSON.Builders.hpp |
System.JSON.Builders | TPairs |
Description
Adds the specified key-value pairs to the JSON object, and returns this instance of TPairs for method chaining.
You may specify the key-value pairs as a JSON builder, a JSON string or an array of constants.
If you use an array of constants, the first value is used as a key, the second value is used as its value, the third value is used as a new key, and so on. You may also use the strings "{", "}", "[" and "]" as items in the array to indicate the beginning and the end of arrays and objects. For example:
Delphi:
MyPairs.AddPairs(['key 1', 'value 1',
'key 2', '[',
'array',
'value',
'2',
']',
'key 3', '{',
'key 3.1',
'value 3.1',
'}']);
C++:
MyPairs->AddPairs(ARRAYOFCONST((String("key 1"), String("value 1"),
String("key 2"), String("["),
String("array"),
String("value"),
String("2"),
String("]"),
String("key 3"), String("{"),
String("key 3.1"),
String("value 3.1"),
String("}")])));
The examples above fill the JSON object with the following key-value pairs:
"key 1": "value 1",
"key 2": [
"array",
"value",
"2"
],
"key 3": {
"key 3.1": "value 3.1"
}
See Also
- System.JSON.Builders.TJSONCollectionBuilder.TPairs.Add
- System.JSON.Builders.TJSONCollectionBuilder.TPairs.AddMaxKey
- System.JSON.Builders.TJSONCollectionBuilder.TPairs.AddMinKey
- System.JSON.Builders.TJSONCollectionBuilder.TPairs.AddNull
- System.JSON.Builders.TJSONCollectionBuilder.TPairs.AddUndefined
- System.JSON.Builders.TJSONCollectionBuilder.TPairs.BeginArray
- System.JSON.Builders.TJSONCollectionBuilder.TPairs.BeginObject