pjson 2.0.0
A small, owning JSON value for C++11
Loading...
Searching...
No Matches
ByteDance::pjson Class Reference

Owning, mutable JSON value with deep-copy semantics. More...

#include <pjson.h>

Classes

struct  Allocator
 Runtime allocator for persistent DOM storage. More...
 
struct  PatchError
 Structured JSON Patch (RFC 6902) / Merge Patch (RFC 7396) failure. More...
 
struct  PatchOptions
 Bounds transactional patch amplification. More...
 
struct  PointerError
 Structured JSON Pointer (RFC 6901) lookup failure. More...
 
struct  SerializeError
 Structured outcome for the non-throwing serialization APIs. More...
 
struct  SerializeOptions
 Controls JSON serialization. More...
 
class  StringView
 Minimal C++11-compatible, non-owning view of a JSON string. More...
 

Public Types

enum  jsonType : int64_t {
  jsonNull = 0 , jsonString , jsonNumberInt , jsonNumberDouble ,
  jsonBoolean , jsonArray , jsonObject , jsonNumberUInt
}
 JSON value kind. More...
 
typedef bool(* ConstMemberVisitor) (StringView aKey, const pjson &aValue, void *aContext)
 Callback for read-only object-member traversal.
 
typedef bool(* MemberVisitor) (StringView aKey, pjson &aValue, void *aContext)
 Callback for mutable object-member traversal.
 
typedef bool(* ConstElementVisitor) (const pjson &aValue, void *aContext)
 Callback for read-only array-element traversal.
 
typedef bool(* ElementVisitor) (pjson &aValue, void *aContext)
 Callback for mutable array-element traversal.
 

Public Member Functions

 pjson () noexcept
 Constructs null using the process-lifetime default allocator.
 
 pjson (Allocator &aAlloc) noexcept
 Constructs null bound to borrowed aAlloc, which must outlive this tree.
 
 ~pjson ()
 Destroys this value and its complete owned subtree.
 
 pjson (const pjson &aFrom)
 Deep-copies aFrom using aFrom's borrowed allocator.
 
 pjson (const pjson &aFrom, Allocator &aAlloc)
 Deep-copies aFrom into borrowed aAlloc.
 
 pjson (pjson &&aFrom) noexcept
 Transfers aFrom's storage and allocator in O(1), leaving aFrom null.
 
 pjson (pjson &&aFrom, Allocator &aAlloc)
 Transfers in O(1) when allocators match; otherwise deep-copies then clears aFrom.
 
pjson & operator= (const pjson &aFrom)
 Deep-copies aFrom while preserving this value's allocator.
 
pjson & operator= (pjson &&aFrom)
 Moves aFrom while preserving this allocator; cross-allocator moves may allocate.
 
void copyFrom (const pjson &aFrom)
 Deep-copies aFrom while preserving this value's allocator.
 
void reset ()
 Destroys the current contents and becomes null.
 
void resetTo (jsonType aeType)
 Replaces the value with the empty/default value of a valid jsonType.
 
void resetIfNeeded (jsonType aeType)
 Calls resetTo() only when the type differs, otherwise preserving contents.
 
void swap (pjson &aOther) noexcept
 Exchanges compatible, non-overlapping contents; otherwise does nothing.
 
Allocator & getAllocator () const noexcept
 Returns the borrowed allocator bound to this value.
 
bool canSwap (const pjson &aOther) const noexcept
 Returns whether swap(aOther) can exchange contents safely.
 
std::string toString () const
 Returns compact JSON using the default serialization options.
 
std::string toString (const SerializeOptions &aOpts) const
 Returns JSON serialized according to aOpts.
 
bool toString (std::string &aOut, SerializeError &aError, const SerializeOptions &aOpts=SerializeOptions()) const noexcept
 Serializes into aOut transactionally and reports failure without throwing.
 
void write (std::ostream &aOut) const
 Writes compact JSON to aOut using the default serialization options.
 
void write (std::ostream &aOut, const SerializeOptions &aOpts) const
 Writes JSON configured by aOpts to aOut.
 
bool write (std::ostream &aOut, SerializeError &aError, const SerializeOptions &aOpts=SerializeOptions()) const noexcept
 Writes JSON and reports logical or physical failure without throwing.
 
jsonType getType () const
 Returns this node's stored JSON representation.
 
bool isNull () const
 Returns whether this node is null.
 
bool isString () const
 Returns whether this node stores a string.
 
bool isNumber () const
 Returns whether this node stores any numeric representation.
 
bool isInt () const
 Returns whether this node stores a signed-integer representation.
 
bool isUInt () const
 Returns whether this node stores an unsigned-integer representation.
 
bool isInteger () const
 Returns whether this node stores any integer representation (signed or unsigned).
 
bool isDouble () const
 Returns whether this node stores a floating-point representation.
 
bool isBool () const
 Returns whether this node stores a boolean.
 
bool isArray () const
 Returns whether this node stores an array.
 
bool isObject () const
 Returns whether this node stores an object.
 
bool tryGet (int64_t &aResult) const noexcept
 Extracts a signed integer; an unsigned value must fit in int64_t.
 
bool tryGet (uint64_t &aResult) const noexcept
 Extracts an unsigned integer; a signed value must be non-negative.
 
bool tryGet (double &aResult) const noexcept
 Extracts a numeric value, widening a stored integer when necessary.
 
bool tryGet (bool &aResult) const noexcept
 Extracts a boolean only when this node stores jsonBoolean.
 
bool tryGet (std::string &aResult) const
 Copies a string only when this node stores jsonString.
 
bool tryGet (StringView &aResult) const noexcept
 Borrows a string view only when this node stores jsonString.
 
size_t size () const
 Returns the element/member count for containers, or zero for scalars.
 
bool empty () const
 Returns whether size() is zero; consequently all scalar values are empty.
 
void clear ()
 Empties a container without changing its type, or resets a scalar to null.
 
std::vector< std::string > keys () const
 Returns copied object keys in unspecified storage order, or an empty vector otherwise.
 
bool forEachMember (ConstMemberVisitor aVisitor, void *aContext) const
 Traversal copies no object names and performs no per-member lookup. Object members are visited in unspecified storage order and array elements in index order. Borrowed arguments are valid only for the callback. The opaque context is forwarded unchanged. Returning false stops early. A callback must not resize the traversed container. Calling a traversal method on the wrong container type is a no-op that returns true. Visits each object member as (key view, const value); false stops early.
 
bool forEachMember (MemberVisitor aVisitor, void *aContext)
 Visits each object member as (key view, mutable value); false stops early.
 
bool forEachElement (ConstElementVisitor aVisitor, void *aContext) const
 Visits each array element as a const value; false stops early.
 
bool forEachElement (ElementVisitor aVisitor, void *aContext)
 Visits each array element as a mutable value; false stops early.
 
bool hasKey (const std::string &aKey) const
 Returns whether this object contains aKey.
 
bool hasKey (const char *aKey) const
 Returns whether this object contains non-null aKey; null returns false.
 
bool contains (const std::string &aKey) const
 Alias for hasKey(aKey); reads more naturally at call sites.
 
bool contains (const char *aKey) const
 Alias for hasKey(aKey); reads more naturally at call sites.
 
bool hasIndex (int aIndex) const noexcept
 Returns whether this array contains aIndex; negative indexes count from the end.
 
pjson * find (const std::string &aKey)
 Returns the borrowed child at aKey, or null when absent or not an object.
 
pjson * find (const char *aKey)
 Returns the borrowed child at non-null aKey, or null on failure.
 
const pjson * find (const std::string &aKey) const
 Returns the read-only borrowed child at aKey, or null on failure.
 
const pjson * find (const char *aKey) const
 Returns the read-only borrowed child at non-null aKey, or null on failure.
 
pjson * find (int aIndex) noexcept
 Returns the borrowed array child at aIndex, or null on failure.
 
const pjson * find (int aIndex) const noexcept
 Returns the read-only borrowed array child at aIndex, or null on failure.
 
pjson * findIndex (size_t aIndex) noexcept
 Returns the borrowed array child at a non-negative index, or null on failure.
 
const pjson * findIndex (size_t aIndex) const noexcept
 Returns the read-only borrowed array child at a non-negative index, or null.
 
pjson * findPointer (const std::string &aPointer)
 Resolves aPointer and returns the borrowed target, or null on failure.
 
const pjson * findPointer (const std::string &aPointer) const
 Resolves aPointer and returns the read-only borrowed target, or null.
 
pjson * findPointer (const std::string &aPointer, PointerError &aError)
 Resolves aPointer and reports lookup failure in aError.
 
const pjson * findPointer (const std::string &aPointer, PointerError &aError) const
 Resolves aPointer read-only and reports lookup failure in aError.
 
pjson * findPointer (const char *aPointer)
 Resolves a non-null pointer string; null returns failure.
 
const pjson * findPointer (const char *aPointer) const
 Resolves a non-null pointer string read-only; null returns failure.
 
pjson * findPointer (const char *aPointer, PointerError &aError)
 Resolves a non-null pointer string and reports failure in aError.
 
const pjson * findPointer (const char *aPointer, PointerError &aError) const
 Resolves a non-null pointer string read-only and reports failure in aError.
 
bool tryGet (const std::string &aKey, int64_t &aResult) const
 Extracts the integer child at aKey without mutating this object.
 
bool tryGet (const std::string &aKey, uint64_t &aResult) const
 Extracts the unsigned-integer child at aKey without mutating this object.
 
bool tryGet (const std::string &aKey, double &aResult) const
 Extracts the numeric child at aKey as a double.
 
bool tryGet (const std::string &aKey, bool &aResult) const
 Extracts the boolean child at aKey.
 
bool tryGet (const std::string &aKey, std::string &aResult) const
 Copies the string child at aKey.
 
bool tryGet (const std::string &aKey, StringView &aResult) const
 Borrows a view of the string child at aKey.
 
bool tryGet (const char *aKey, int64_t &aResult) const
 Extracts the integer child at non-null aKey.
 
bool tryGet (const char *aKey, uint64_t &aResult) const
 Extracts the unsigned-integer child at non-null aKey.
 
bool tryGet (const char *aKey, double &aResult) const
 Extracts the numeric child at non-null aKey as a double.
 
bool tryGet (const char *aKey, bool &aResult) const
 Extracts the boolean child at non-null aKey.
 
bool tryGet (const char *aKey, std::string &aResult) const
 Copies the string child at non-null aKey.
 
bool tryGet (const char *aKey, StringView &aResult) const
 Borrows a view of the string child at non-null aKey.
 
bool tryGet (int aIndex, int64_t &aResult) const noexcept
 Extracts the integer array child at aIndex.
 
bool tryGet (int aIndex, uint64_t &aResult) const noexcept
 Extracts the unsigned-integer array child at aIndex.
 
bool tryGet (int aIndex, double &aResult) const noexcept
 Extracts the numeric array child at aIndex as a double.
 
bool tryGet (int aIndex, bool &aResult) const noexcept
 Extracts the boolean array child at aIndex.
 
bool tryGet (int aIndex, std::string &aResult) const
 Copies the string array child at aIndex.
 
bool tryGet (int aIndex, StringView &aResult) const noexcept
 Borrows a view of the string array child at aIndex.
 
pjson & operator[] (const std::string &aString)
 Returns or creates the child at aString.
 
pjson & operator[] (const char *aSkey)
 Returns or creates the child at aSkey; throws std::invalid_argument for null.
 
pjson & operator[] (int index)
 Returns or creates the child at index under the auto-growth rules above.
 
pjson & operator[] (size_t index)
 Returns or creates the child at a non-negative index.
 
pjson & operator= (std::nullptr_t)
 Replaces this value with JSON null (std::nullptr_t assignment).
 
pjson & at (const std::string &aKey)
 Returns the existing child at aKey or throws std::out_of_range.
 
const pjson & at (const std::string &aKey) const
 Returns the read-only child at aKey or throws std::out_of_range.
 
pjson & at (size_t aIndex)
 Returns the existing element at aIndex or throws std::out_of_range.
 
const pjson & at (size_t aIndex) const
 Returns the read-only element at aIndex or throws std::out_of_range.
 
pjson & pushBack (const pjson &aValue)
 Appends a deep copy of aValue, promoting this node to an array.
 
pjson & pushBack (pjson &&aValue)
 Moves an independent same-allocator value; otherwise deep-copies it.
 
pjson & insertOrAssign (const std::string &aKey, const pjson &aValue)
 Inserts or replaces the member aKey with a deep copy of aValue.
 
pjson & insertOrAssign (const std::string &aKey, pjson &&aValue)
 Moves an independent same-allocator value; otherwise deep-copies it.
 
pjson & reserve (size_t aCount)
 Reserves capacity for at least aCount array elements (no-op for non-arrays unless this node is first made an array); returns *this for chaining.
 
pjson & operator= (const std::string &aString)
 Replaces this value with a copy of aString.
 
pjson & operator= (const char *aCString)
 Replaces this value with aCString; throws std::invalid_argument for null.
 
pjson & operator= (const bool aBool)
 Replaces this value with aBool.
 
pjson & operator= (const int aInt)
 Replaces this value with a signed integer.
 
pjson & operator= (const unsigned int aUInt)
 Replaces this value with an unsigned integer.
 
pjson & operator= (const short aInt)
 Replaces this value with a signed short integer.
 
pjson & operator= (const unsigned short aUInt)
 Replaces this value with an unsigned short integer.
 
pjson & operator= (const long aInt)
 Replaces this value with a signed long integer.
 
pjson & operator= (const unsigned long aUInt)
 Replaces this value with an unsigned long integer.
 
pjson & operator= (const long long aInt)
 Replaces this value with a signed long-long integer.
 
pjson & operator= (const unsigned long long aUInt)
 Replaces this value with an unsigned long-long integer.
 
pjson & operator= (const float aFloat)
 Replaces this value with a floating-point number.
 
pjson & operator= (const double aDouble)
 Replaces this value with aDouble; the non-finite policy governs output.
 
pjson & operator= (const long double aDouble)
 Narrows a long double to the library's binary64 number representation.
 
pjson & operator= (const std::vector< std::string > &aValueArray)
 Replaces this value with a copied string array.
 
pjson & operator= (const std::vector< bool > &aValueArray)
 Replaces this value with a copied boolean array.
 
pjson & operator= (const std::vector< int > &aValueArray)
 Replaces this value with a copied native-integer array.
 
pjson & operator= (const std::vector< unsigned int > &aValueArray)
 Replaces this value with a copied native unsigned-integer array.
 
pjson & operator= (const std::vector< short > &aValueArray)
 Replaces this value with a copied signed-short array.
 
pjson & operator= (const std::vector< unsigned short > &aValueArray)
 Replaces this value with a copied unsigned-short array.
 
pjson & operator= (const std::vector< long > &aValueArray)
 Replaces this value with a copied signed-long array.
 
pjson & operator= (const std::vector< unsigned long > &aValueArray)
 Replaces this value with a copied unsigned-long array.
 
pjson & operator= (const std::vector< long long > &aValueArray)
 Replaces this value with a copied signed-long-long array.
 
pjson & operator= (const std::vector< unsigned long long > &aValueArray)
 Replaces this value with a copied unsigned-long-long array.
 
pjson & operator= (const std::vector< float > &aValueArray)
 Replaces this value with a copied float array.
 
pjson & operator= (const std::vector< double > &aValueArray)
 Replaces this value with a copied double array.
 
pjson & operator= (const std::vector< long double > &aValueArray)
 Replaces this value with a copied long-double array, narrowing each value to double.
 
pjson & operator+= (const std::string &aValue)
 Appends a copy of aValue as a string child.
 
pjson & operator+= (const char *aValue)
 Appends aValue as a string child; throws std::invalid_argument for null.
 
pjson & operator+= (const bool aValue)
 Appends aValue as a boolean child.
 
pjson & operator+= (const int aValue)
 Appends aValue as a signed integer child.
 
pjson & operator+= (const unsigned int aValue)
 Appends aValue as an unsigned integer child.
 
pjson & operator+= (const short aValue)
 Appends aValue as a signed-short child.
 
pjson & operator+= (const unsigned short aValue)
 Appends aValue as an unsigned-short child.
 
pjson & operator+= (const long aValue)
 Appends aValue as a signed-long child.
 
pjson & operator+= (const unsigned long aValue)
 Appends aValue as an unsigned-long child.
 
pjson & operator+= (const long long aValue)
 Appends aValue as a signed-long-long child.
 
pjson & operator+= (const unsigned long long aValue)
 Appends aValue as an unsigned-long-long child.
 
pjson & operator+= (const float aValue)
 Appends aValue as a floating-point child.
 
pjson & operator+= (const double aValue)
 Appends aValue as a double child.
 
pjson & operator+= (const long double aValue)
 Narrows aValue to the library's binary64 number representation and appends it.
 
pjson & operator+= (const std::vector< std::string > &aValueArray)
 Appends every string in aValueArray.
 
pjson & operator+= (const std::vector< bool > &aValueArray)
 Appends every boolean in aValueArray.
 
pjson & operator+= (const std::vector< int > &aValueArray)
 Appends every native integer in aValueArray.
 
pjson & operator+= (const std::vector< unsigned int > &aValueArray)
 Appends every native unsigned integer in aValueArray.
 
pjson & operator+= (const std::vector< short > &aValueArray)
 Appends every signed short in aValueArray.
 
pjson & operator+= (const std::vector< unsigned short > &aValueArray)
 Appends every unsigned short in aValueArray.
 
pjson & operator+= (const std::vector< long > &aValueArray)
 Appends every signed long in aValueArray.
 
pjson & operator+= (const std::vector< unsigned long > &aValueArray)
 Appends every unsigned long in aValueArray.
 
pjson & operator+= (const std::vector< long long > &aValueArray)
 Appends every signed long long in aValueArray.
 
pjson & operator+= (const std::vector< unsigned long long > &aValueArray)
 Appends every unsigned long long in aValueArray.
 
pjson & operator+= (const std::vector< float > &aValueArray)
 Appends every float in aValueArray.
 
pjson & operator+= (const std::vector< double > &aValueArray)
 Appends every double in aValueArray.
 
pjson & operator+= (const std::vector< long double > &aValueArray)
 Narrows and appends every long double in aValueArray.
 
bool erase (const std::string &aKey)
 Erases aKey and returns whether an object member was removed.
 
bool erase (const char *aKey)
 Erases non-null aKey; null or a non-object returns false.
 
bool erase (size_t aIndex)
 Erases aIndex and returns whether an array element was removed.
 
bool applyPatch (const pjson &aPatch, const PatchOptions &aOpts=PatchOptions()) noexcept
 Atomically applies an RFC 6902 patch document.
 
bool applyPatch (const pjson &aPatch, PatchError &aError, const PatchOptions &aOpts=PatchOptions()) noexcept
 Atomically applies RFC 6902 and reports failure details in aError.
 
bool applyMergePatch (const pjson &aPatch, const PatchOptions &aOpts=PatchOptions()) noexcept
 Atomically applies an RFC 7396 Merge Patch document.
 
bool applyMergePatch (const pjson &aPatch, PatchError &aError, const PatchOptions &aOpts=PatchOptions()) noexcept
 Atomically applies RFC 7396 and reports failure details in aError.
 
bool operator== (const pjson &aOther) const
 Returns whether this value and aOther are structurally equal.
 
bool operator!= (const pjson &aOther) const
 Returns the negation of operator==.
 
bool tryCompareNumber (const pjson &aOther, int &aOrder) const noexcept
 Compares two stored numbers exactly; false when non-numeric/unordered.
 

Static Public Member Functions

static const char * getVersion ()
 Returns the process-lifetime semantic-version string for this library.
 
static std::string escapePointerToken (const std::string &aToken)
 Escapes one decoded reference token for inclusion in a JSON Pointer.
 
static pjson null ()
 Returns a JSON null value.
 
static pjson object ()
 Returns an empty JSON object value.
 
static pjson array ()
 Returns an empty JSON array value.
 

Detailed Description

Owning, mutable JSON value with deep-copy semantics.

An owning, mutable value that represents every JSON type.

Child pointers and string views exposed by lookup/access APIs are borrowed from the owning tree. They become invalid when the child or an ancestor is destroyed, replaced, reset, erased, moved, swapped, cleared, or successfully patched. Unless an operation is noexcept or explicitly reports failures, allocation and standard-library exceptions may escape.

A pjson owns its complete subtree. Copies are deep, and pointers returned by find() or findPointer(), along with string views returned by tryGet(), remain borrowed from their owning tree. Parsing is provided by the independent ByteDance::pJsonParser class rather than by pjson members.

Every value is bound to a runtime allocator. Default construction uses the built-in allocator; allocator-aware construction and pJsonParser use a borrowed pjson::Allocator that must outlive the complete tree. Copy and move assignment preserve the destination allocator. Storage transfer and swap are O(1) only between values with the same allocator; use canSwap() when allocator provenance may differ. Every pJsonParser DOM operation returns the parsed document by value, bound to the chosen allocator and freed on destruction; pass a pJsonParser::Error to distinguish failure from a successfully parsed literal null.

operator[] is the auto-vivifying builder API. For observation without mutation, use find(), findIndex(), findPointer(), hasKey(), hasIndex(), at(), contains(), forEachMember()/forEachElement(), or tryGet(). tryGet() requires the requested stored type and leaves its output unchanged on failure; integer-to-double widening and exact signed/unsigned integer reads are permitted. Containers expose query and child-lookup operations rather than their raw storage types.

getType() distinguishes jsonNumberInt, jsonNumberUInt, and jsonNumberDouble and reports objects as jsonObject. Numeric assignment and append overloads accept the standard non-character integral and floating-point types. Configure serialization through SerializeOptions; the compact toString() and write() overloads take no formatting boolean, and SerializeOptions::maxOutputBytes bounds generated output. A stored non-finite double fails serialization by default; select an explicit SerializeOptions::NonFinitePolicy to map it. PatchOptions bounds transactional JSON Patch and Merge Patch amplification. Invalid UTF-8 and logical output-size failures are detected before write() emits bytes.

See also
https://github.com/Pico-Developer/pjson/tree/main/docs Tutorials
migration-nlohmann-json
migration-rapidjson

Definition at line 68 of file pjson.h.

Member Typedef Documentation

◆ ConstElementVisitor

typedef bool(* ByteDance::pjson::ConstElementVisitor) (const pjson &aValue, void *aContext)

Callback for read-only array-element traversal.

Definition at line 410 of file pjson.h.

◆ ConstMemberVisitor

typedef bool(* ByteDance::pjson::ConstMemberVisitor) (StringView aKey, const pjson &aValue, void *aContext)

Callback for read-only object-member traversal.

Definition at line 406 of file pjson.h.

◆ ElementVisitor

typedef bool(* ByteDance::pjson::ElementVisitor) (pjson &aValue, void *aContext)

Callback for mutable array-element traversal.

Definition at line 412 of file pjson.h.

◆ MemberVisitor

typedef bool(* ByteDance::pjson::MemberVisitor) (StringView aKey, pjson &aValue, void *aContext)

Callback for mutable object-member traversal.

Definition at line 408 of file pjson.h.

Member Enumeration Documentation

◆ jsonType

JSON value kind.

Numbers are stored in one of three representations: signed whole numbers as a 64-bit signed integer (jsonNumberInt), explicitly unsigned whole numbers as a 64-bit unsigned integer (jsonNumberUInt), and fractional/exponent values as a double (jsonNumberDouble).

Enumerator
jsonNull 

JSON null and the stable default discriminator.

jsonString 

UTF-8 string value.

jsonNumberInt 

Signed 64-bit integer value.

jsonNumberDouble 

Binary64 number value.

jsonBoolean 

Boolean value.

jsonArray 

Ordered array value.

jsonObject 

Object with unique string keys.

jsonNumberUInt 

Unsigned 64-bit integer value.

Definition at line 82 of file pjson.h.

Constructor & Destructor Documentation

◆ pjson() [1/6]

ByteDance::pjson::pjson ( )
noexcept

Constructs null using the process-lifetime default allocator.

◆ pjson() [2/6]

ByteDance::pjson::pjson ( Allocator &  aAlloc)
explicitnoexcept

Constructs null bound to borrowed aAlloc, which must outlive this tree.

◆ ~pjson()

ByteDance::pjson::~pjson ( )

Destroys this value and its complete owned subtree.

◆ pjson() [3/6]

ByteDance::pjson::pjson ( const pjson &  aFrom)

Deep-copies aFrom using aFrom's borrowed allocator.

◆ pjson() [4/6]

ByteDance::pjson::pjson ( const pjson &  aFrom,
Allocator &  aAlloc 
)

Deep-copies aFrom into borrowed aAlloc.

◆ pjson() [5/6]

ByteDance::pjson::pjson ( pjson &&  aFrom)
noexcept

Transfers aFrom's storage and allocator in O(1), leaving aFrom null.

◆ pjson() [6/6]

ByteDance::pjson::pjson ( pjson &&  aFrom,
Allocator &  aAlloc 
)

Transfers in O(1) when allocators match; otherwise deep-copies then clears aFrom.

Member Function Documentation

◆ applyMergePatch() [1/2]

bool ByteDance::pjson::applyMergePatch ( const pjson &  aPatch,
const PatchOptions &  aOpts = PatchOptions() 
)
noexcept

Atomically applies an RFC 7396 Merge Patch document.

◆ applyMergePatch() [2/2]

bool ByteDance::pjson::applyMergePatch ( const pjson &  aPatch,
PatchError &  aError,
const PatchOptions &  aOpts = PatchOptions() 
)
noexcept

Atomically applies RFC 7396 and reports failure details in aError.

◆ applyPatch() [1/2]

bool ByteDance::pjson::applyPatch ( const pjson &  aPatch,
const PatchOptions &  aOpts = PatchOptions() 
)
noexcept

Atomically applies an RFC 6902 patch document.

◆ applyPatch() [2/2]

bool ByteDance::pjson::applyPatch ( const pjson &  aPatch,
PatchError &  aError,
const PatchOptions &  aOpts = PatchOptions() 
)
noexcept

Atomically applies RFC 6902 and reports failure details in aError.

◆ array()

static pjson ByteDance::pjson::array ( )
static

Returns an empty JSON array value.

◆ at() [1/4]

pjson & ByteDance::pjson::at ( const std::string &  aKey)

Returns the existing child at aKey or throws std::out_of_range.

◆ at() [2/4]

const pjson & ByteDance::pjson::at ( const std::string &  aKey) const

Returns the read-only child at aKey or throws std::out_of_range.

◆ at() [3/4]

pjson & ByteDance::pjson::at ( size_t  aIndex)

Returns the existing element at aIndex or throws std::out_of_range.

◆ at() [4/4]

const pjson & ByteDance::pjson::at ( size_t  aIndex) const

Returns the read-only element at aIndex or throws std::out_of_range.

◆ canSwap()

bool ByteDance::pjson::canSwap ( const pjson &  aOther) const
noexcept

Returns whether swap(aOther) can exchange contents safely.

◆ clear()

void ByteDance::pjson::clear ( )

Empties a container without changing its type, or resets a scalar to null.

◆ contains() [1/2]

bool ByteDance::pjson::contains ( const char *  aKey) const

Alias for hasKey(aKey); reads more naturally at call sites.

◆ contains() [2/2]

bool ByteDance::pjson::contains ( const std::string &  aKey) const

Alias for hasKey(aKey); reads more naturally at call sites.

◆ copyFrom()

void ByteDance::pjson::copyFrom ( const pjson &  aFrom)

Deep-copies aFrom while preserving this value's allocator.

◆ empty()

bool ByteDance::pjson::empty ( ) const

Returns whether size() is zero; consequently all scalar values are empty.

◆ erase() [1/3]

bool ByteDance::pjson::erase ( const char *  aKey)

Erases non-null aKey; null or a non-object returns false.

◆ erase() [2/3]

bool ByteDance::pjson::erase ( const std::string &  aKey)

Erases aKey and returns whether an object member was removed.

◆ erase() [3/3]

bool ByteDance::pjson::erase ( size_t  aIndex)

Erases aIndex and returns whether an array element was removed.

◆ escapePointerToken()

static std::string ByteDance::pjson::escapePointerToken ( const std::string &  aToken)
static

Escapes one decoded reference token for inclusion in a JSON Pointer.

◆ find() [1/6]

pjson * ByteDance::pjson::find ( const char *  aKey)

Returns the borrowed child at non-null aKey, or null on failure.

◆ find() [2/6]

const pjson * ByteDance::pjson::find ( const char *  aKey) const

Returns the read-only borrowed child at non-null aKey, or null on failure.

◆ find() [3/6]

pjson * ByteDance::pjson::find ( const std::string &  aKey)

Returns the borrowed child at aKey, or null when absent or not an object.

◆ find() [4/6]

const pjson * ByteDance::pjson::find ( const std::string &  aKey) const

Returns the read-only borrowed child at aKey, or null on failure.

◆ find() [5/6]

const pjson * ByteDance::pjson::find ( int  aIndex) const
noexcept

Returns the read-only borrowed array child at aIndex, or null on failure.

◆ find() [6/6]

pjson * ByteDance::pjson::find ( int  aIndex)
noexcept

Returns the borrowed array child at aIndex, or null on failure.

◆ findIndex() [1/2]

const pjson * ByteDance::pjson::findIndex ( size_t  aIndex) const
noexcept

Returns the read-only borrowed array child at a non-negative index, or null.

◆ findIndex() [2/2]

pjson * ByteDance::pjson::findIndex ( size_t  aIndex)
noexcept

Returns the borrowed array child at a non-negative index, or null on failure.

◆ findPointer() [1/8]

pjson * ByteDance::pjson::findPointer ( const char *  aPointer)

Resolves a non-null pointer string; null returns failure.

◆ findPointer() [2/8]

const pjson * ByteDance::pjson::findPointer ( const char *  aPointer) const

Resolves a non-null pointer string read-only; null returns failure.

◆ findPointer() [3/8]

pjson * ByteDance::pjson::findPointer ( const char *  aPointer,
PointerError &  aError 
)

Resolves a non-null pointer string and reports failure in aError.

◆ findPointer() [4/8]

const pjson * ByteDance::pjson::findPointer ( const char *  aPointer,
PointerError &  aError 
) const

Resolves a non-null pointer string read-only and reports failure in aError.

◆ findPointer() [5/8]

pjson * ByteDance::pjson::findPointer ( const std::string &  aPointer)

Resolves aPointer and returns the borrowed target, or null on failure.

◆ findPointer() [6/8]

const pjson * ByteDance::pjson::findPointer ( const std::string &  aPointer) const

Resolves aPointer and returns the read-only borrowed target, or null.

◆ findPointer() [7/8]

pjson * ByteDance::pjson::findPointer ( const std::string &  aPointer,
PointerError &  aError 
)

Resolves aPointer and reports lookup failure in aError.

◆ findPointer() [8/8]

const pjson * ByteDance::pjson::findPointer ( const std::string &  aPointer,
PointerError &  aError 
) const

Resolves aPointer read-only and reports lookup failure in aError.

◆ forEachElement() [1/2]

bool ByteDance::pjson::forEachElement ( ConstElementVisitor  aVisitor,
void *  aContext 
) const

Visits each array element as a const value; false stops early.

◆ forEachElement() [2/2]

bool ByteDance::pjson::forEachElement ( ElementVisitor  aVisitor,
void *  aContext 
)

Visits each array element as a mutable value; false stops early.

◆ forEachMember() [1/2]

bool ByteDance::pjson::forEachMember ( ConstMemberVisitor  aVisitor,
void *  aContext 
) const

Traversal copies no object names and performs no per-member lookup. Object members are visited in unspecified storage order and array elements in index order. Borrowed arguments are valid only for the callback. The opaque context is forwarded unchanged. Returning false stops early. A callback must not resize the traversed container. Calling a traversal method on the wrong container type is a no-op that returns true. Visits each object member as (key view, const value); false stops early.

◆ forEachMember() [2/2]

bool ByteDance::pjson::forEachMember ( MemberVisitor  aVisitor,
void *  aContext 
)

Visits each object member as (key view, mutable value); false stops early.

◆ getAllocator()

Allocator & ByteDance::pjson::getAllocator ( ) const
noexcept

Returns the borrowed allocator bound to this value.

◆ getType()

jsonType ByteDance::pjson::getType ( ) const

Returns this node's stored JSON representation.

◆ getVersion()

static const char * ByteDance::pjson::getVersion ( )
static

Returns the process-lifetime semantic-version string for this library.

◆ hasIndex()

bool ByteDance::pjson::hasIndex ( int  aIndex) const
noexcept

Returns whether this array contains aIndex; negative indexes count from the end.

◆ hasKey() [1/2]

bool ByteDance::pjson::hasKey ( const char *  aKey) const

Returns whether this object contains non-null aKey; null returns false.

◆ hasKey() [2/2]

bool ByteDance::pjson::hasKey ( const std::string &  aKey) const

Returns whether this object contains aKey.

◆ insertOrAssign() [1/2]

pjson & ByteDance::pjson::insertOrAssign ( const std::string &  aKey,
const pjson &  aValue 
)

Inserts or replaces the member aKey with a deep copy of aValue.

◆ insertOrAssign() [2/2]

pjson & ByteDance::pjson::insertOrAssign ( const std::string &  aKey,
pjson &&  aValue 
)

Moves an independent same-allocator value; otherwise deep-copies it.

◆ isArray()

bool ByteDance::pjson::isArray ( ) const

Returns whether this node stores an array.

◆ isBool()

bool ByteDance::pjson::isBool ( ) const

Returns whether this node stores a boolean.

◆ isDouble()

bool ByteDance::pjson::isDouble ( ) const

Returns whether this node stores a floating-point representation.

◆ isInt()

bool ByteDance::pjson::isInt ( ) const

Returns whether this node stores a signed-integer representation.

◆ isInteger()

bool ByteDance::pjson::isInteger ( ) const

Returns whether this node stores any integer representation (signed or unsigned).

◆ isNull()

bool ByteDance::pjson::isNull ( ) const

Returns whether this node is null.

◆ isNumber()

bool ByteDance::pjson::isNumber ( ) const

Returns whether this node stores any numeric representation.

◆ isObject()

bool ByteDance::pjson::isObject ( ) const

Returns whether this node stores an object.

◆ isString()

bool ByteDance::pjson::isString ( ) const

Returns whether this node stores a string.

◆ isUInt()

bool ByteDance::pjson::isUInt ( ) const

Returns whether this node stores an unsigned-integer representation.

◆ keys()

std::vector< std::string > ByteDance::pjson::keys ( ) const

Returns copied object keys in unspecified storage order, or an empty vector otherwise.

◆ null()

static pjson ByteDance::pjson::null ( )
static

Returns a JSON null value.

◆ object()

static pjson ByteDance::pjson::object ( )
static

Returns an empty JSON object value.

◆ operator!=()

bool ByteDance::pjson::operator!= ( const pjson &  aOther) const

Returns the negation of operator==.

◆ operator+=() [1/27]

pjson & ByteDance::pjson::operator+= ( const bool  aValue)

Appends aValue as a boolean child.

◆ operator+=() [2/27]

pjson & ByteDance::pjson::operator+= ( const char *  aValue)

Appends aValue as a string child; throws std::invalid_argument for null.

◆ operator+=() [3/27]

pjson & ByteDance::pjson::operator+= ( const double  aValue)

Appends aValue as a double child.

◆ operator+=() [4/27]

pjson & ByteDance::pjson::operator+= ( const float  aValue)

Appends aValue as a floating-point child.

◆ operator+=() [5/27]

pjson & ByteDance::pjson::operator+= ( const int  aValue)

Appends aValue as a signed integer child.

◆ operator+=() [6/27]

pjson & ByteDance::pjson::operator+= ( const long  aValue)

Appends aValue as a signed-long child.

◆ operator+=() [7/27]

pjson & ByteDance::pjson::operator+= ( const long double  aValue)

Narrows aValue to the library's binary64 number representation and appends it.

◆ operator+=() [8/27]

pjson & ByteDance::pjson::operator+= ( const long long  aValue)

Appends aValue as a signed-long-long child.

◆ operator+=() [9/27]

pjson & ByteDance::pjson::operator+= ( const short  aValue)

Appends aValue as a signed-short child.

◆ operator+=() [10/27]

pjson & ByteDance::pjson::operator+= ( const std::string &  aValue)

Appends a copy of aValue as a string child.

◆ operator+=() [11/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< bool > &  aValueArray)

Appends every boolean in aValueArray.

◆ operator+=() [12/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< double > &  aValueArray)

Appends every double in aValueArray.

◆ operator+=() [13/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< float > &  aValueArray)

Appends every float in aValueArray.

◆ operator+=() [14/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< int > &  aValueArray)

Appends every native integer in aValueArray.

◆ operator+=() [15/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< long > &  aValueArray)

Appends every signed long in aValueArray.

◆ operator+=() [16/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< long double > &  aValueArray)

Narrows and appends every long double in aValueArray.

◆ operator+=() [17/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< long long > &  aValueArray)

Appends every signed long long in aValueArray.

◆ operator+=() [18/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< short > &  aValueArray)

Appends every signed short in aValueArray.

◆ operator+=() [19/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< std::string > &  aValueArray)

Appends every string in aValueArray.

◆ operator+=() [20/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< unsigned int > &  aValueArray)

Appends every native unsigned integer in aValueArray.

◆ operator+=() [21/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< unsigned long > &  aValueArray)

Appends every unsigned long in aValueArray.

◆ operator+=() [22/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< unsigned long long > &  aValueArray)

Appends every unsigned long long in aValueArray.

◆ operator+=() [23/27]

pjson & ByteDance::pjson::operator+= ( const std::vector< unsigned short > &  aValueArray)

Appends every unsigned short in aValueArray.

◆ operator+=() [24/27]

pjson & ByteDance::pjson::operator+= ( const unsigned int  aValue)

Appends aValue as an unsigned integer child.

◆ operator+=() [25/27]

pjson & ByteDance::pjson::operator+= ( const unsigned long  aValue)

Appends aValue as an unsigned-long child.

◆ operator+=() [26/27]

pjson & ByteDance::pjson::operator+= ( const unsigned long long  aValue)

Appends aValue as an unsigned-long-long child.

◆ operator+=() [27/27]

pjson & ByteDance::pjson::operator+= ( const unsigned short  aValue)

Appends aValue as an unsigned-short child.

◆ operator=() [1/30]

pjson & ByteDance::pjson::operator= ( const bool  aBool)

Replaces this value with aBool.

◆ operator=() [2/30]

pjson & ByteDance::pjson::operator= ( const char *  aCString)

Replaces this value with aCString; throws std::invalid_argument for null.

◆ operator=() [3/30]

pjson & ByteDance::pjson::operator= ( const double  aDouble)

Replaces this value with aDouble; the non-finite policy governs output.

◆ operator=() [4/30]

pjson & ByteDance::pjson::operator= ( const float  aFloat)

Replaces this value with a floating-point number.

◆ operator=() [5/30]

pjson & ByteDance::pjson::operator= ( const int  aInt)

Replaces this value with a signed integer.

◆ operator=() [6/30]

pjson & ByteDance::pjson::operator= ( const long  aInt)

Replaces this value with a signed long integer.

◆ operator=() [7/30]

pjson & ByteDance::pjson::operator= ( const long double  aDouble)

Narrows a long double to the library's binary64 number representation.

◆ operator=() [8/30]

pjson & ByteDance::pjson::operator= ( const long long  aInt)

Replaces this value with a signed long-long integer.

◆ operator=() [9/30]

pjson & ByteDance::pjson::operator= ( const pjson &  aFrom)

Deep-copies aFrom while preserving this value's allocator.

◆ operator=() [10/30]

pjson & ByteDance::pjson::operator= ( const short  aInt)

Replaces this value with a signed short integer.

◆ operator=() [11/30]

pjson & ByteDance::pjson::operator= ( const std::string &  aString)

Replaces this value with a copy of aString.

◆ operator=() [12/30]

pjson & ByteDance::pjson::operator= ( const std::vector< bool > &  aValueArray)

Replaces this value with a copied boolean array.

◆ operator=() [13/30]

pjson & ByteDance::pjson::operator= ( const std::vector< double > &  aValueArray)

Replaces this value with a copied double array.

◆ operator=() [14/30]

pjson & ByteDance::pjson::operator= ( const std::vector< float > &  aValueArray)

Replaces this value with a copied float array.

◆ operator=() [15/30]

pjson & ByteDance::pjson::operator= ( const std::vector< int > &  aValueArray)

Replaces this value with a copied native-integer array.

◆ operator=() [16/30]

pjson & ByteDance::pjson::operator= ( const std::vector< long > &  aValueArray)

Replaces this value with a copied signed-long array.

◆ operator=() [17/30]

pjson & ByteDance::pjson::operator= ( const std::vector< long double > &  aValueArray)

Replaces this value with a copied long-double array, narrowing each value to double.

◆ operator=() [18/30]

pjson & ByteDance::pjson::operator= ( const std::vector< long long > &  aValueArray)

Replaces this value with a copied signed-long-long array.

◆ operator=() [19/30]

pjson & ByteDance::pjson::operator= ( const std::vector< short > &  aValueArray)

Replaces this value with a copied signed-short array.

◆ operator=() [20/30]

pjson & ByteDance::pjson::operator= ( const std::vector< std::string > &  aValueArray)

Replaces this value with a copied string array.

◆ operator=() [21/30]

pjson & ByteDance::pjson::operator= ( const std::vector< unsigned int > &  aValueArray)

Replaces this value with a copied native unsigned-integer array.

◆ operator=() [22/30]

pjson & ByteDance::pjson::operator= ( const std::vector< unsigned long > &  aValueArray)

Replaces this value with a copied unsigned-long array.

◆ operator=() [23/30]

pjson & ByteDance::pjson::operator= ( const std::vector< unsigned long long > &  aValueArray)

Replaces this value with a copied unsigned-long-long array.

◆ operator=() [24/30]

pjson & ByteDance::pjson::operator= ( const std::vector< unsigned short > &  aValueArray)

Replaces this value with a copied unsigned-short array.

◆ operator=() [25/30]

pjson & ByteDance::pjson::operator= ( const unsigned int  aUInt)

Replaces this value with an unsigned integer.

◆ operator=() [26/30]

pjson & ByteDance::pjson::operator= ( const unsigned long  aUInt)

Replaces this value with an unsigned long integer.

◆ operator=() [27/30]

pjson & ByteDance::pjson::operator= ( const unsigned long long  aUInt)

Replaces this value with an unsigned long-long integer.

◆ operator=() [28/30]

pjson & ByteDance::pjson::operator= ( const unsigned short  aUInt)

Replaces this value with an unsigned short integer.

◆ operator=() [29/30]

pjson & ByteDance::pjson::operator= ( pjson &&  aFrom)

Moves aFrom while preserving this allocator; cross-allocator moves may allocate.

◆ operator=() [30/30]

pjson & ByteDance::pjson::operator= ( std::nullptr_t  )

Replaces this value with JSON null (std::nullptr_t assignment).

◆ operator==()

bool ByteDance::pjson::operator== ( const pjson &  aOther) const

Returns whether this value and aOther are structurally equal.

◆ operator[]() [1/4]

pjson & ByteDance::pjson::operator[] ( const char *  aSkey)

Returns or creates the child at aSkey; throws std::invalid_argument for null.

◆ operator[]() [2/4]

pjson & ByteDance::pjson::operator[] ( const std::string &  aString)

Returns or creates the child at aString.

◆ operator[]() [3/4]

pjson & ByteDance::pjson::operator[] ( int  index)

Returns or creates the child at index under the auto-growth rules above.

◆ operator[]() [4/4]

pjson & ByteDance::pjson::operator[] ( size_t  index)

Returns or creates the child at a non-negative index.

◆ pushBack() [1/2]

pjson & ByteDance::pjson::pushBack ( const pjson &  aValue)

Appends a deep copy of aValue, promoting this node to an array.

◆ pushBack() [2/2]

pjson & ByteDance::pjson::pushBack ( pjson &&  aValue)

Moves an independent same-allocator value; otherwise deep-copies it.

◆ reserve()

pjson & ByteDance::pjson::reserve ( size_t  aCount)

Reserves capacity for at least aCount array elements (no-op for non-arrays unless this node is first made an array); returns *this for chaining.

◆ reset()

void ByteDance::pjson::reset ( )

Destroys the current contents and becomes null.

◆ resetIfNeeded()

void ByteDance::pjson::resetIfNeeded ( jsonType  aeType)

Calls resetTo() only when the type differs, otherwise preserving contents.

◆ resetTo()

void ByteDance::pjson::resetTo ( jsonType  aeType)

Replaces the value with the empty/default value of a valid jsonType.

◆ size()

size_t ByteDance::pjson::size ( ) const

Returns the element/member count for containers, or zero for scalars.

◆ swap()

void ByteDance::pjson::swap ( pjson &  aOther)
noexcept

Exchanges compatible, non-overlapping contents; otherwise does nothing.

◆ toString() [1/3]

std::string ByteDance::pjson::toString ( ) const

Returns compact JSON using the default serialization options.

◆ toString() [2/3]

std::string ByteDance::pjson::toString ( const SerializeOptions &  aOpts) const

Returns JSON serialized according to aOpts.

◆ toString() [3/3]

bool ByteDance::pjson::toString ( std::string &  aOut,
SerializeError &  aError,
const SerializeOptions &  aOpts = SerializeOptions() 
) const
noexcept

Serializes into aOut transactionally and reports failure without throwing.

◆ tryCompareNumber()

bool ByteDance::pjson::tryCompareNumber ( const pjson &  aOther,
int &  aOrder 
) const
noexcept

Compares two stored numbers exactly; false when non-numeric/unordered.

◆ tryGet() [1/24]

bool ByteDance::pjson::tryGet ( bool &  aResult) const
noexcept

Extracts a boolean only when this node stores jsonBoolean.

◆ tryGet() [2/24]

bool ByteDance::pjson::tryGet ( const char *  aKey,
bool &  aResult 
) const

Extracts the boolean child at non-null aKey.

◆ tryGet() [3/24]

bool ByteDance::pjson::tryGet ( const char *  aKey,
double &  aResult 
) const

Extracts the numeric child at non-null aKey as a double.

◆ tryGet() [4/24]

bool ByteDance::pjson::tryGet ( const char *  aKey,
int64_t &  aResult 
) const

Extracts the integer child at non-null aKey.

◆ tryGet() [5/24]

bool ByteDance::pjson::tryGet ( const char *  aKey,
std::string &  aResult 
) const

Copies the string child at non-null aKey.

◆ tryGet() [6/24]

bool ByteDance::pjson::tryGet ( const char *  aKey,
StringView &  aResult 
) const

Borrows a view of the string child at non-null aKey.

◆ tryGet() [7/24]

bool ByteDance::pjson::tryGet ( const char *  aKey,
uint64_t &  aResult 
) const

Extracts the unsigned-integer child at non-null aKey.

◆ tryGet() [8/24]

bool ByteDance::pjson::tryGet ( const std::string &  aKey,
bool &  aResult 
) const

Extracts the boolean child at aKey.

◆ tryGet() [9/24]

bool ByteDance::pjson::tryGet ( const std::string &  aKey,
double &  aResult 
) const

Extracts the numeric child at aKey as a double.

◆ tryGet() [10/24]

bool ByteDance::pjson::tryGet ( const std::string &  aKey,
int64_t &  aResult 
) const

Extracts the integer child at aKey without mutating this object.

◆ tryGet() [11/24]

bool ByteDance::pjson::tryGet ( const std::string &  aKey,
std::string &  aResult 
) const

Copies the string child at aKey.

◆ tryGet() [12/24]

bool ByteDance::pjson::tryGet ( const std::string &  aKey,
StringView &  aResult 
) const

Borrows a view of the string child at aKey.

◆ tryGet() [13/24]

bool ByteDance::pjson::tryGet ( const std::string &  aKey,
uint64_t &  aResult 
) const

Extracts the unsigned-integer child at aKey without mutating this object.

◆ tryGet() [14/24]

bool ByteDance::pjson::tryGet ( double &  aResult) const
noexcept

Extracts a numeric value, widening a stored integer when necessary.

◆ tryGet() [15/24]

bool ByteDance::pjson::tryGet ( int  aIndex,
bool &  aResult 
) const
noexcept

Extracts the boolean array child at aIndex.

◆ tryGet() [16/24]

bool ByteDance::pjson::tryGet ( int  aIndex,
double &  aResult 
) const
noexcept

Extracts the numeric array child at aIndex as a double.

◆ tryGet() [17/24]

bool ByteDance::pjson::tryGet ( int  aIndex,
int64_t &  aResult 
) const
noexcept

Extracts the integer array child at aIndex.

◆ tryGet() [18/24]

bool ByteDance::pjson::tryGet ( int  aIndex,
std::string &  aResult 
) const

Copies the string array child at aIndex.

◆ tryGet() [19/24]

bool ByteDance::pjson::tryGet ( int  aIndex,
StringView &  aResult 
) const
noexcept

Borrows a view of the string array child at aIndex.

◆ tryGet() [20/24]

bool ByteDance::pjson::tryGet ( int  aIndex,
uint64_t &  aResult 
) const
noexcept

Extracts the unsigned-integer array child at aIndex.

◆ tryGet() [21/24]

bool ByteDance::pjson::tryGet ( int64_t &  aResult) const
noexcept

Extracts a signed integer; an unsigned value must fit in int64_t.

◆ tryGet() [22/24]

bool ByteDance::pjson::tryGet ( std::string &  aResult) const

Copies a string only when this node stores jsonString.

◆ tryGet() [23/24]

bool ByteDance::pjson::tryGet ( StringView &  aResult) const
noexcept

Borrows a string view only when this node stores jsonString.

◆ tryGet() [24/24]

bool ByteDance::pjson::tryGet ( uint64_t &  aResult) const
noexcept

Extracts an unsigned integer; a signed value must be non-negative.

◆ write() [1/3]

void ByteDance::pjson::write ( std::ostream &  aOut) const

Writes compact JSON to aOut using the default serialization options.

◆ write() [2/3]

void ByteDance::pjson::write ( std::ostream &  aOut,
const SerializeOptions &  aOpts 
) const

Writes JSON configured by aOpts to aOut.

◆ write() [3/3]

bool ByteDance::pjson::write ( std::ostream &  aOut,
SerializeError &  aError,
const SerializeOptions &  aOpts = SerializeOptions() 
) const
noexcept

Writes JSON and reports logical or physical failure without throwing.


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