AFLOW
 
Loading...
Searching...
No Matches
aurostd_xparser_json.h File Reference
#include <cmath>
#include <cstddef>
#include <deque>
#include <iosfwd>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "aurostd_type_traits.tpp"
#include "aurostd_xcomplex.h"
#include "aurostd_xfile.h"
#include "aurostd_xmatrix.h"
#include "aurostd_xvector.h"
#include "aurostd_xparser_json.tpp"

Go to the source code of this file.

Classes

struct  aurostd::JSON::object
 storge container for a JSON object More...
 

Namespaces

namespace  aurostd
 
namespace  aurostd::JSON
 unified namespace to read and write JSON
 

Typedefs

template<typename T>
using aurostd::JSON::is_string_like = std::is_same<std::decay_t<T>, std::string>
 
template<typename T>
using aurostd::JSON::is_json_list_like = std::conjunction<aurostd::is_list_like<T>, std::negation<is_string_like<T>>>
 
template<typename T>
using aurostd::JSON::enable_list_like = std::enable_if_t<is_json_list_like<T>::value, bool>
 
template<typename T>
using aurostd::JSON::enable_dict_like = std::enable_if_t<aurostd::is_dict_like_v<T>, bool>
 
template<typename T>
using aurostd::JSON::enable_serializable = std::enable_if_t<std::is_base_of_v<JsonSerializable<T>, T>, bool>
 
template<typename T>
using aurostd::JSON::enable_arithmetic = std::enable_if_t<std::is_arithmetic_v<T>, bool>
 
typedef std::vector< objectaurostd::JSON::List
 shortcut for JSON::object_types::LIST
 
typedef std::map< std::string, objectaurostd::JSON::Dictionary
 shortcut for JSON::object_types::DICTIONARY
 

Enumerations

enum class  aurostd::JSON::object_types {
  aurostd::JSON::DICTIONARY , aurostd::JSON::LIST , aurostd::JSON::STRING , aurostd::JSON::FLOAT ,
  aurostd::JSON::INTEGER , aurostd::JSON::T , aurostd::JSON::F , aurostd::JSON::NONE
}
 

Functions

std::string aurostd::JSON::unescape_unicode (const std::string &raw, size_t &pos)
 unescape JSON unicode instances
 
std::string aurostd::JSON::escape (const std::string &raw, bool unicode=true)
 prepare string for JSON output with or without Unicode escapes
 
std::string aurostd::JSON::char32_to_string (char32_t cp)
 convert a unicode codepoint to a series of utf8 chars
 
std::string aurostd::JSON::char_escape (char16_t c)
 escape characters to JSON
 
object aurostd::JSON::loadFile (const std::string &file_path)
 create a JSON::object from file
 
object aurostd::JSON::loadString (const std::string &content)
 create a JSON::object from raw string
 
void aurostd::JSON::saveFile (const object &root, const std::string &file_path, compression_type ct=compression_type::None, bool escape_unicode=true)
 save JSON::object to file
 
std::string aurostd::JSON::toString (const object &root, bool escape_unicode=false)
 convert JSON::object to string
 
std::pair< size_t, size_t > aurostd::JSON::find_string (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0})
 find the border of a JSON string
 
std::pair< size_t, size_t > aurostd::JSON::find_bracket (const std::string &raw_content, char kind_open, std::pair< size_t, size_t > border={0, 0})
 find the border of an encapsulated by brackets
 
std::pair< size_t, size_t > aurostd::JSON::find_strip (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0})
 strip whitespaces
 
object aurostd::JSON::parse (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0})
 parse a raw JSON string
 
std::string aurostd::JSON::parse_string (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0})
 parse JSON string
 
std::ostream & aurostd::operator<< (std::ostream &os, const JSON::object &jo)