API Documentation
|
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text to transmit data objects consisting of attribute–value pairs and array data types(or any other serializable value). More...
#include <JSONParser.h>
Public Types | |
enum | NodeType { e_number , e_array , e_bool , e_object , e_node , e_root } |
Public Member Functions | |
JSONNode () | |
JSONNode (const JSONNode &node) | |
JSONNode (JSONNode &&node) noexcept | |
JSONNode (Scanner &scan) | |
JSONNode (const String &node, const String &json_string) | |
JSONNode (File &file) | |
~JSONNode () | |
NodeType | type () const |
void | write (String &stream) const |
void | write (File &file) |
Writes the JSON structure out to a file with no frills. Same as write(String&) but for files. | |
void | write (std::ostream &file) |
void | writePretty (String &stream, const uint04 tab_indention=0) const |
Same as write, but adds tabs and new lines to make it easier to read, though will result in larger file. | |
void | writePretty (File &file) |
Writes our structure out to a file using tabs and new lines. Same as writePretty(String&) but for files. | |
void | writePretty (std::ostream &file) |
template<class t_type > | |
decltype(auto) | getAs () const |
const JSONNode & | get (const String &child_node) const |
const JSONNode & | operator[] (const String &child_node) const |
JSONNode & | operator[] (const String &child_node) |
JSONNode & | operator[] (const uint04 &child_idx) |
const JSONNode & | operator[] (const uint04 &child_idx) const |
const Buffer< JSONNode * > & | children () const |
bool | hasNode (const String &child_node) const |
const String & | nodeName () const |
void | remove (const String &child_node) |
JSONNode & | createChildNode (const String &child_node, NodeType type) |
JSONNode & | operator= (const JSONNode &node) |
JSONNode & | operator= (const String &value) |
template<class t_type > | |
JSONNode & | operator= (const Angle< t_type > &value) |
JSONNode & | operator= (const Time &time) |
template<class t_type , class t_allocator > | |
JSONNode & | operator= (const Buffer< t_type, t_allocator > &buffer) |
template<uint01 t_dims, class t_type > | |
JSONNode & | operator= (const Vector< t_dims, t_type > &buffer) |
bool | isEmpty () const |
template<class t_type > | |
JSONNode & | operator= (const t_type &value) |
uint04 | size () |
decltype(auto) | begin () |
decltype(auto) | begin () const |
decltype(auto) | end () |
decltype(auto) | end () const |
Static Public Member Functions | |
static JSONNode | ParseYAML (Scanner &scan) |
Protected Member Functions | |
JSONNode (const String &name) | |
bool | parseJSON (Scanner &scan) |
bool | parseJSONContent (char start, Scanner &scan) |
bool | parseYAMLContent (uint04 indentention, Scanner &scan) |
void | readChildrenNodes (Scanner &scan) |
void | readData (Scanner &scan) |
void | readArray (Scanner &scan) |
Static Protected Member Functions | |
static void | WriteTabs (String &stream, uint04 tab_indention) |
static void | ConvertToJSONString (String &string) |
static void | ConvertFromJSONString (String &string) |
static TranslatedString | UnexpectedCharErrorString (char current_char, const Scanner &scan) |
static TranslatedString | DuplicateChildErrorString (const String &child, const Scanner &scan) |
static TranslatedString | BadChildErrorString (const Scanner &scan) |
Protected Attributes | |
Buffer< JSONNode * > | m_sorted_json_children |
Dictionary< String, JSONNode * > | m_json_children |
const String | m_name |
String | m_value |
NodeType | m_type |
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text to transmit data objects consisting of attribute–value pairs and array data types(or any other serializable value).
Class: JSONNode
It is a very common data format used for asynchronous browser–server communication, including as a replacement for XML in some AJAX - style systems.
The JSONNode class serves as a container for data and it's children. Includes options to read and write from streams and files.
Author: Tyler Parke
enum NodeType |
JSONNode | ( | ) |
Fn: JSONNode::JSONNode(const String& name)
Creates a root JSON node
Author: Tyler Parke
Fn: JSONNode::JSONNode(const String& name)
Creates a JSONNode with a given name
Author: Tyler Parke
Fn: JSONNode::JSONNode(const JSONNode& node)
Very basic copy constructor.
Author: Tyler Parke
Fn: JSONNode::JSONNode(Scanner& scan)
Creates a JSONNode by parsing it from the scanner. Scanner should be at the start of the file or stream just before the opening '{'
Author: Tyler Parke
Fn: JSONNode::JSONNode(File& scan)
Creates a JSONNode by parsing it from the File.
Author: Tyler Parke
~JSONNode | ( | ) |
|
staticprotected |
|
inlinenodiscard |
|
inlinenodiscard |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
inlinenodiscard |
|
inlinenodiscard |
Fn: const JSONNode& JSONNode::get(const String& child_node) const
returns the child, if it exists. Is read only. Same as (*this)[child_node]
Author: Tyler Parke
Date: 2017-11-19
Parameters:
|
inline |
Fn: void JSONNode::getAs()
Returns this object as the type specified.
Author: Tyler Parke
|
inline |
|
inlinenodiscard |
Fn: bool JSONNode::isEmpty() const
Returns true if the node contains no information.
Author: Tyler Parke
|
inline |
|
inline |
Fn: void JSONNode::operator=(const JSONNode& node)
A special case of the = operator for nodes. Note that this will not set the name of the node, but set the contents equal to that of another
Author: Tyler Parke
|
inline |
Fn: void JSONNode::operator=(const t_type& node)
A general case t_type equals. Sets the value internal and predicts the type.
Author: Tyler Parke
Fn: void JSONNode::operator=(const Time& node)
A special case Time equals. writes in YYYY/MM/DDTHH:mm:ss.fffZ format.
Author: Tyler Parke
|
inline |
Fn: const JSONNode& JSONNode::operator[](const String& child_node) const
returns the child, if it exists. Is read only. Same as get
Author: Tyler Parke
Date: 2017-11-19
Parameters:
Fn: JSONNode& JSONNode::operator[](const uint04& child_node)
Returns the child, if it exists.
Author: Tyler Parke
Date: 2017-11-19
Parameters:
|
protected |
Fn: JSONParser::parseJSON(Scanner& scan)
Reads in the next JSON item and adds it to this node's children
Parameters: scan - The object tasked with reading in our data. Shold be just past the second '"' at the end of the node's title at this point.
Author: Tyler Parke
Date: 2017-11-19
Returns: true if there is an adjacent child next to this one, false if end of stream or no additional
|
protected |
Fn: JSONParser::parseYAML(Scanner& scan)
Reads in the next YAML item and adds it to this node's children
Parameters: scan - The object tasked with reading in our data. Shold be just past the second '"' at the end of the node's title at this point.
Author: Tyler Parke
Date: 2024-07-08
Returns: true if there is an adjacent child next to this one, false if end of stream or no additional
|
protected |
|
protected |
|
protected |
void remove | ( | const String & | child_node | ) |
|
inline |
Fn: void JSONNode::operator=()
Returns the number of children within this node.
Author: Tyler Parke
JSONNode::NodeType type | ( | ) | const |
Fn: NodeType JSONNode::type() const
Author: Tyler Parke
Date: 2017-11-19
Returns: The type of the node which will give a hint as to how the contents should be written to
|
staticprotected |
void write | ( | File & | file | ) |
Writes the JSON structure out to a file with no frills. Same as write(String&) but for files.
Fn: void JSONNode::write(File& file)
Author: Tyler Parke
Date: 2017-11-19
Parameters:
void write | ( | std::ostream & | file | ) |
void write | ( | String & | stream | ) | const |
Fn: void JSONNode::write(String& stream) const
A no frills write routine. Useful for writing to a file.
Author: Tyler Parke
Date: 2017-11-19
Parameters:
void writePretty | ( | File & | file | ) |
Writes our structure out to a file using tabs and new lines. Same as writePretty(String&) but for files.
Fn: void JSONNode::writePretty(File& file)
Author: Tyler Parke
Date: 2017-11-19
Parameters:
void writePretty | ( | std::ostream & | file | ) |
Same as write, but adds tabs and new lines to make it easier to read, though will result in larger file.
Fn: void JSONNode::writePretty(String& stream, const uint04 tab_indention = 0) const
Author: Tyler Parke
Date: 2017-11-19
Parameters: stream - The stream where you want the JSON node to be written
|
protected |
|
protected |
|
protected |
|
protected |