### Iterating GSON C++ Document Elements Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Provides a loop example to iterate through all elements in a parsed Gson::doc. It shows how to access the index, type, key, value, and parent index of each element. ```CPP for (uint16_t i = 0; i doc;// Static document reserved for 10 elements ``` -------------------------------- ### GSON C++ String Building Methods Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Lists the methods available for building a JSON string using the GSON::String class, including adding keys, raw text, strings, booleans, floats, integers, and managing object/array structure. ```CPP String S;// Access to the line Void Clear ();// Clean the line Bool Reserve (Uint16_T Res);// Reserve a line // Add Gson :: String.A comma will be added String & Add (Constation String & STR); // Add the key (string of any type) String & Addkey (Anytext Key); // add text (string of any type) String & Addraw (Anytext Str, Bool ESC = FALSE); // Add a line (a string of any type) String & Addstr (Anytext Key, Anytext Value); String & Addstr (Anytext Value); // Add bool String & Addbool (Anytext Key, Const Bool & Value); String & Addbool (Const Bool & Value); // Add Float String & Addfloat (Anytext Key, const Double & Value, Uint8_t Dec = 2); String & Addfloat (Constance Double & Value, Uint8_t Dec = 2); // Add int String & Addint (Anytext Key, Const ANYVALUE & VALUE); String & Addint (Const ANYVALUE & VALUE); String & Beginobj (Anytext Key = "");// Start an object String & Endobj ();// Complete the object String & Beginarr (Anytext Key = "");// Start an array String & Endarr ();// End the array String & End ();// complete the package ``` -------------------------------- ### Using GSON C++ Entry Objects Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Shows how to obtain a Gson::Entry object for a specific element (like an array) using doc[...] and then access its properties (LENGTH()) and elements (E[...]) directly, avoiding repeated lookups in the main document. ```CPP GSON :: Entry E = doc ["arr"]; Serial.println (E.LENGTH ());// The length of the array Serial.println (E [0]);// Hello Serial.println (E [1]);// True ``` -------------------------------- ### Accessing GSON Elements by Hashed Key (CPP) Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Demonstrates accessing GSON document elements using the `SH()` macro with hashed keys. The `SH()` macro computes the hash at compile time, substituting a number for the string, which improves performance. ```CPP USing Sutil :: SH; VOID FOO () { Serial.println (doc [SH ("int")]); Serial.println (doc [SH ("Obj")] [SH ("Float")]); Serial.println (doc [SH ("Array")] [0]); } ``` -------------------------------- ### Gson Document Class Methods (C++) Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Defines the constructors and core methods available for interacting with a Gson document object, including parsing, accessing elements by key or index, checking for errors, and serializing the document. ```C++ // Designer Gson :: doc (); GSON :: doc (size); GSON :: doCstatic (); // Methods uint16_t Length ();// get the number of elements uint16_t size ();// get the size of the document in RAM (byte) Void Hashkeys ();// Heshcht the keys of all elements (the operation is irreversible) Bool Hashed ();// Checking whether the keys were drunken Entry Get (Anytext Key);// Key access (main container - Object) Entry Get (Size_t Hash);// Access to Hash Key (main container - Object) Entry Get (Int Index);// Access by index (main container - Array or Object) Anytext Key (Intx);// Read the key on the index size_t keyhash (int IDX);// Read the Hesh key on the index Anytext Value (Intx);// Read the value by index int8_t part (int itx);// Read the parent on the index Type Type (int IDX);// get the type of index const __flashstringhelper* readtype (Uint16_T IDX);// Read the type of index // Parish.True will return with successful parsing.You can specify Max.The level of investment Bool Parse (String & Json, Uint8_t Maxdepth = 16); Bool Parse (Const Char* Json, Uint8_t Maxdepth = 16); // Bring out to Print with formatting VOID stringify (print& p); // error processing Bool Haserror ();// there is a parsing error Error Geterror ();// get an error uint16_t errorindex ();// Index of the place of error in the line const __flashstringhelper* readerror ();// Read the error ``` -------------------------------- ### Hashing GSON Document Keys (CPP) Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Hashes the keys within a GSON document using `doc.hashkeys()` for faster access. Note that this operation is irreversible and prevents reading keys in text form. ```CPP doc.hashkeys (); ``` -------------------------------- ### Parsing JSON String with GSON C++ Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Shows how to parse a C-style string or String object containing JSON using doc.parse(). Includes error checking using doc.Haserror(), doc.earaderror(), and doc.errorindex(). Notes that parsing modifies the original string. ```CPP ``` -------------------------------- ### Gson Parsing Error Codes (C++) Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Lists the specific error codes that the Gson library can return to indicate issues encountered during the JSON parsing process, such as allocation failures, depth limits, or malformed tokens. ```C++ None Alloc Toodeep NopARENT NotContainer UNEXCOMMA Unexcolon UNEXTOKEN Unexquotes Unexopen Unexclose Unknowntoken Brokentoken Brokenstring BrokenContainer Emptyky Indexoverflow ``` -------------------------------- ### Gson Element Types (C++) Source: https://github.com/gyverlibs/gson/blob/main/README_EN.md Enumerates the different data types that a JSON element can represent within the Gson library, such as Object, Array, String, numbers, and boolean. ```C++ None Object Array String Int Float Bool ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.