Uniot Core
0.8.1
Loading...
Searching...
No Matches
uniot::JSON::Object Class Reference

JSON object builder for creating key-value pairs. More...

#include <MicroJSON.h>

Public Member Functions

 Object (String &out)
 Construct a new JSON Object.
 
Objectput (const String &key, const String &value, bool quote=true)
 Add a string key-value pair to the object.
 
Objectput (const String &key, int value)
 Add an integer key-value pair to the object.
 
Array putArray (const String &key)
 Create a nested array for the given key.
 
Object putObject (const String &key)
 Create a nested object for the given key.
 
void close ()
 Close the JSON object by appending the closing brace.
 

Detailed Description

JSON object builder for creating key-value pairs.

This class provides a fluent interface for building JSON objects by appending key-value pairs to a String buffer. It automatically handles JSON formatting including quotes, commas, and braces.

Constructor & Destructor Documentation

◆ Object()

uniot::JSON::Object::Object ( String & out)
inline

Construct a new JSON Object.

Parameters
outReference to the String buffer where JSON will be written

Member Function Documentation

◆ close()

void uniot::JSON::Object::close ( )
inline

Close the JSON object by appending the closing brace.

◆ put() [1/2]

Object & uniot::JSON::Object::put ( const String & key,
const String & value,
bool quote = true )
inline

Add a string key-value pair to the object.

Parameters
keyThe key name
valueThe string value
quoteWhether to quote the value (default: true)
Return values
Object&Reference to this object for method chaining

◆ put() [2/2]

Object & uniot::JSON::Object::put ( const String & key,
int value )
inline

Add an integer key-value pair to the object.

Parameters
keyThe key name
valueThe integer value
Return values
Object&Reference to this object for method chaining

◆ putArray()

Array uniot::JSON::Object::putArray ( const String & key)
inline

Create a nested array for the given key.

Parameters
keyThe key name for the array
Return values
ArrayNew Array object for the nested array

◆ putObject()

Object uniot::JSON::Object::putObject ( const String & key)
inline

Create a nested object for the given key.

Parameters
keyThe key name for the nested object
Return values
ObjectNew Object for the nested object

The documentation for this class was generated from the following file: