System.JSON.Builders.TJSONObjectBuilder

From RAD Studio API Documentation
Jump to: navigation, search

System.JSON.Builders.TJSONCollectionBuilderSystem.TObjectTJSONObjectBuilder

Delphi

TJSONObjectBuilder = class(TJSONCollectionBuilder)

C++

class PASCALIMPLEMENTATION TJSONObjectBuilder : public TJSONCollectionBuilder

Properties

Type Visibility Source Unit Parent
class public
System.JSON.Builders.pas
System.JSON.Builders.hpp
System.JSON.Builders System.JSON.Builders

Description

JSON writer wrapper that provides a fluent interface to write a JSON object.

Call BeginObject to start writing your object. Clear deletes the content of the object builder.

Example

The examples below write the following object:

{
  "key 1": "value 1",
  "key 2": "value 2"
}

Delphi:

with TJSONObjectBuilder.Create(MyJSONWriter) do
try
  BeginObject
    .Add('key 1', 'value 1')
    .Add('key 2', 'value 2');
finally
  Free;
end;

C++:

TJSONObjectBuilder* MyObjectBuilder = new TJSONObjectBuilder(MyJSONWriter);
try {
  MyObjectBuilder
    ->BeginObject()
      ->Add("key 1", String("value 1"))
      ->Add("key 2", String("value 2"));
} __finally {
  delete MyObjectBuilder;
}

See Also