|
JsonParserGeneratorRK
|
Creates a JsonWriter with a statically allocated buffer. More...
#include <JsonParserGeneratorRK.h>
Additional Inherited Members | |
Public Member Functions inherited from JsonWriter | |
| JsonWriter () | |
| Construct a JsonWriter with a dynamically allocated buffer. More... | |
| virtual | ~JsonWriter () |
| Destroy the object. If the buffer was dynamically allocated it will be freed. More... | |
| JsonWriter (char *buffer, size_t bufferLen) | |
| Construct a JsonWriter to write to a static buffer. More... | |
| void | init () |
| Reset the writer, clearing all data. More... | |
| bool | startObject () |
| Start a new JSON object. Make sure you finish it with finishObjectOrArray() | |
| bool | startArray () |
| Start a new JSON array. Make sure you finish it with finishObjectOrArray() | |
| void | finishObjectOrArray () |
| Finsh an object or array started with startObject() or startArray() | |
| void | insertValue (bool value) |
| Inserts a boolean value ("true" or "false"). More... | |
| void | insertValue (int value) |
| Inserts an integer value. More... | |
| void | insertValue (unsigned int value) |
| Inserts an unsigned integer value. More... | |
| void | insertValue (long value) |
| Inserts a long integer value. More... | |
| void | insertValue (unsigned long value) |
| Inserts an unsigned long integer value. More... | |
| void | insertValue (float value) |
| Inserts a floating point value. More... | |
| void | insertValue (double value) |
| Inserts a floating point double value. More... | |
| void | insertValue (const char *value) |
| Inserts a quoted string value. This escapes special characters and encodes utf-8. More... | |
| void | insertValue (const String &value) |
| Inserts a quoted string value. More... | |
| void | insertKeyObject (const char *key) |
| Inserts a new key and empty object. You must close the object using finishObjectOrArray()! More... | |
| void | insertKeyArray (const char *key) |
| Inserts a new key and empty array. You must close the object using finishObjectOrArray()! More... | |
| template<class T > | |
| void | insertKeyValue (const char *key, T value) |
| Inserts a key/value pair into an object. More... | |
| template<class T > | |
| void | insertArrayValue (T value) |
| Inserts a value into an array. More... | |
| bool | isTruncated () const |
| void | setFloatPlaces (int floatPlaces) |
| Sets the number of digits for formatting float and double values. More... | |
| void | insertCheckSeparator () |
| Check to see if a separator needs to be inserted. Used internally. More... | |
| bool | startObjectOrArray (char startChar, char endChar) |
| Used internally to start an object or array. More... | |
| void | insertChar (char ch) |
| Used internally to insert a character. More... | |
| void | insertString (const char *s, bool quoted=false) |
| Used internally to insert a string, quoted or not. More... | |
| void | insertsprintf (const char *fmt,...) |
| Used internally to insert using snprintf formatting. More... | |
| void | insertvsprintf (const char *fmt, va_list ap) |
| Used internally to insert using snprintf formatting with a va_list. More... | |
| void | setIsFirst (bool isFirst=true) |
| Used internally to set the current isFirst flag in the context. | |
Public Member Functions inherited from JsonBuffer | |
| JsonBuffer () | |
| Construct a JsonBuffer object with no external buffer specified. | |
| virtual | ~JsonBuffer () |
| Destructor. Destroying the object does not delete any underlying buffer! | |
| JsonBuffer (char *buffer, size_t bufferLen) | |
| Construct a JsonBuffer with an external buffer of a given size. More... | |
| void | setBuffer (char *buffer, size_t bufferLen) |
| Sets the buffers to the specified buffer and length. More... | |
| bool | allocate (size_t len) |
| Allocate the buffer using malloc/realloc. More... | |
| bool | addString (const char *data) |
| Add a c-string to the end of the buffer. More... | |
| bool | addData (const char *data, size_t dataLen) |
| Add a string to the end of the buffer. More... | |
| char * | getBuffer () const |
| Gets a pointer to the internal buffer. More... | |
| size_t | getOffset () const |
| Gets the current offset for writing. | |
| void | setOffset (size_t offset) |
| swets the current offset for writing | |
| size_t | getBufferLen () const |
| Gets the current length of the buffer. More... | |
| void | clear () |
| Clears the current buffer for writing. More... | |
Static Public Attributes inherited from JsonWriter | |
| static const size_t | MAX_NESTED_CONTEXT = 9 |
Protected Attributes inherited from JsonWriter | |
| size_t | contextIndex |
| Index into the context for the current level of nesting. | |
| JsonWriterContext | context [MAX_NESTED_CONTEXT] |
| Structure for managing nested objects. | |
| bool | truncated |
| true if data was added that didn't fit and was truncated | |
| int | floatPlaces |
| default number of places to display for floating point numbers (default is -1, the default for sprintf) | |
Protected Attributes inherited from JsonBuffer | |
| char * | buffer |
| The buffer to to read from or write to. This is not null-terminated. | |
| size_t | bufferLen |
| The length of the buffer in bytes,. | |
| size_t | offset |
| The read or write offset. | |
| bool | staticBuffers |
| True if the buffers were passed in and should not freed or reallocated. | |
Creates a JsonWriter with a statically allocated buffer.
You typically do this when you want to create a buffer as a global variable.
Example:
Creates a 256 byte buffer to write JSON to. You'd normally do this as a global variable, but for smaller buffers (256 and smaller should be fine) in the loop thread, you can allocate one on the stack as a local variable.
| BUFFER_SIZE | The size of the buffer to reserve. |
1.8.14