CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
jsonParser.hh
Go to the documentation of this file.
1 #ifndef CASM_JSONPARSER_HH
2 #define CASM_JSONPARSER_HH
3 
4 #include "casm/external/json_spirit/json_spirit_reader_template.h"
5 #include "casm/external/json_spirit/json_spirit_writer_template.h"
6 
7 #include "casm/misc/CASM_TMP.hh"
8 
9 #include <exception>
10 #include <complex>
11 
12 #include "casm/external/boost.hh"
13 
14 namespace CASM {
15 
16  template<bool IsConst>
18 
29  class jsonParser : public json_spirit::mValue {
79 
80  public:
81 
82  typedef json_spirit::mObject::size_type size_type;
85 
86  // ---- Constructors ----------------------------------
87 
90  json_spirit::mValue(json_spirit::mObject()) {}
91 
95  template<typename T>
96  explicit jsonParser(T &t) {
97  to_json(t, *this);
98  }
99 
103  template<typename T>
104  explicit jsonParser(const T &t) {
105  to_json(t, *this);
106  }
107 
108 
109  // ---- Read/Print JSON ----------------------------------
110 
112  bool read(std::istream &stream);
113 
115  bool read(const boost::filesystem::path &mypath);
116 
117 
119  void print(std::ostream &stream, unsigned int indent = 2, unsigned int prec = 12) const;
120 
122  void write(const std::string &file_name, unsigned int indent = 2, unsigned int prec = 12) const;
123 
125  void write(const boost::filesystem::path &mypath, unsigned int indent = 2, unsigned int prec = 12) const;
126 
127 
128  // ---- Value level printing options: ---------------------
129 
131  using json_spirit::mValue::set_force_column;
132 
134  using json_spirit::mValue::set_force_row;
135 
137  using json_spirit::mValue::set_scientific;
138 
140  using json_spirit::mValue::set_remove_trailing_zeros;
141 
143  using json_spirit::mValue::unset_force_column;
144 
146  using json_spirit::mValue::unset_force_row;
147 
149  using json_spirit::mValue::unset_scientific;
150 
152  using json_spirit::mValue::unset_remove_trailing_zeros;
153 
154 
155  using json_spirit::mValue::operator==;
156 
157  bool operator!=(const jsonParser &json) const {
158  return !(json_spirit::mValue::operator==(json));
159  }
160 
161  bool almost_equal(const jsonParser &B, double tol) const;
162 
163 
164  // ------ Type Checking Methods ------------------------------------
165 
166  bool is_null() const;
167  bool is_bool() const;
168  bool is_int() const;
169  bool is_number() const;
170  bool is_string() const;
171  bool is_obj() const;
172  bool is_array() const;
173 
174 
175  // ---- Navigate the JSON data: ----------------------------
176 
179  jsonParser &operator[](const std::string &name);
180 
183  const jsonParser &operator[](const std::string &name) const;
184 
190  jsonParser &at(const fs::path &path);
191 
197  const jsonParser &at(const fs::path &path) const;
198 
200  jsonParser &operator[](const int &element);
201 
203  const jsonParser &operator[](const int &element) const;
204 
206  size_type size() const;
207 
209  iterator begin();
210 
212  const_iterator begin() const;
213 
215  iterator end();
216 
218  const_iterator end() const;
219 
221  const_iterator cbegin() const;
222 
224  const_iterator cend() const;
225 
226 
228  iterator find(const std::string &name);
229 
231  const_iterator find(const std::string &name) const;
232 
234  bool contains(const std::string &name) const;
235 
237  size_type erase(const std::string &name);
238 
239  // ---- Data-retrieval Methods -----------------------------------------
240 
242  template<typename T, typename...Args>
243  T get(Args... args) const;
244 
247  template<typename T, typename...Args>
248  void get(T &t, Args... args) const;
249 
252  template<typename T, typename...Args>
253  bool get_if(T &t, const std::string &key, Args... args) const;
254 
257  template<typename T, typename...Args>
258  bool get_else(T &t, const std::string &key, const T &default_value, Args... args) const;
259 
260 
261  // ---- Data addition Methods (Overwrites any existing data with same 'name') ---
262 
264  template<typename T>
265  jsonParser &operator=(const T &value);
266 
268  template<typename T>
269  jsonParser &push_back(const T &value);
270 
272  template<typename T>
273  jsonParser &put(const T &value);
274 
277  return *this = object();
278  }
279 
281  template<typename Iterator>
282  jsonParser &put_obj(Iterator begin, Iterator end);
283 
286  return *this = array();
287  }
288 
290  jsonParser &put_array(size_type N) {
291  return *this = array(N);
292  }
293 
295  template<typename T>
296  jsonParser &put_array(size_type N, const T &t);
297 
299  template<typename Iterator>
300  jsonParser &put_array(Iterator begin,
301  Iterator end,
302  typename CASM_TMP::enable_if_iterator<Iterator>::type * = nullptr);
303 
306  return *this = null();
307  }
308 
309  // ---- static Methods -------------------------------------
310 
312  static jsonParser parse(const std::string &str) {
313  std::stringstream ss;
314  ss << str;
315  return jsonParser(ss);
316  }
317 
319  static jsonParser parse(const fs::path &path) {
320  return jsonParser(path);
321  }
322 
324  static jsonParser parse(std::istream &stream) {
325  return jsonParser(stream);
326  }
327 
329  static jsonParser object() {
330  jsonParser json;
331  return json = json_spirit::mValue(json_spirit::mObject());
332  }
333 
335  template<typename Iterator>
336  static jsonParser object(Iterator begin, Iterator end) {
337  jsonParser json;
338  return json.put_obj(begin, end);
339  }
340 
342  static jsonParser array() {
343  jsonParser json;
344  return json = json_spirit::mValue(json_spirit::mArray());
345  }
346 
348  static jsonParser array(size_type N) {
349  jsonParser json;
350  return json = json_spirit::mValue(json_spirit::mArray(N));
351  }
352 
354  template<typename T>
355  static jsonParser array(size_type N, const T &t) {
356  jsonParser json;
357  return json.put_array(N, t);
358  }
359 
361  template<typename Iterator>
362  static jsonParser array(Iterator begin,
363  Iterator end,
364  typename CASM_TMP::enable_if_iterator<Iterator>::type * = nullptr) {
365  jsonParser json;
366  return json.put_array(begin, end);
367  }
368 
369 
371  static jsonParser null() {
372  jsonParser json;
373  return json = json_spirit::mValue();
374  }
375 
376  private:
377 
378  jsonParser &operator=(const json_spirit::mValue &value) {
379  this->json_spirit::mValue::operator=(value);
380  return *this;
381  }
382 
383 
384  };
385 
386  std::ostream &operator<<(std::ostream &stream, const jsonParser &json);
387  std::istream &operator>>(std::istream &stream, jsonParser &json);
388 
390  jsonParser &to_json(bool value, jsonParser &json);
391  jsonParser &to_json(int value, jsonParser &json);
392  jsonParser &to_json(unsigned int value, jsonParser &json);
393  jsonParser &to_json(long int value, jsonParser &json);
394  jsonParser &to_json(unsigned long int value, jsonParser &json);
395  jsonParser &to_json(double value, jsonParser &json);
396  jsonParser &to_json(const std::string &value, jsonParser &json);
397  jsonParser &to_json(const char *value, jsonParser &json);
398  jsonParser &to_json(const jsonParser &value, jsonParser &json);
399 
400 
402  template<typename T>
403  T from_json(const jsonParser &json);
404 
405 
406  template<> bool from_json<bool>(const jsonParser &json);
407  template<> int from_json<int>(const jsonParser &json);
408  template<> unsigned int from_json<unsigned int>(const jsonParser &json);
409  template<> long int from_json<long int>(const jsonParser &json);
410  template<> unsigned long int from_json<unsigned long int>(const jsonParser &json);
411  template<> double from_json<double>(const jsonParser &json);
412  template<> std::string from_json<std::string>(const jsonParser &json);
413  template<> jsonParser from_json<jsonParser>(const jsonParser &json);
414 
416  void from_json(bool &value, const jsonParser &json);
417  void from_json(int &value, const jsonParser &json);
418  void from_json(unsigned int &value, const jsonParser &json);
419  void from_json(long int &value, const jsonParser &json);
420  void from_json(unsigned long int &value, const jsonParser &json);
421  void from_json(double &value, const jsonParser &json);
422  void from_json(std::string &value, const jsonParser &json);
423  void from_json(jsonParser &value, const jsonParser &json);
424  void from_json(std::istream &stream, const jsonParser &json);
425  void from_json(fs::path &value, const jsonParser &json);
426 
428  inline void to_json(std::istream &stream, jsonParser &json) {
429  if(!json.read(stream)) {
430  throw std::runtime_error(
431  std::string("ERROR: Could not read JSON. Please check your formatting. "
432  "For instance, try http://www.jsoneditoronline.org."));
433  }
434  }
435 
440  inline void to_json(fs::path file_path, jsonParser &json) {
441  if(!json.read(file_path)) {
442  throw std::runtime_error(
443  std::string("ERROR: Could not read JSON file: '") + file_path.string() +
444  "'.\n\nPlease check your formatting. For instance, try http://www.jsoneditoronline.org.");
445  }
446  }
447 
449  template<typename T>
450  jsonParser &to_json(const std::complex<T> &value, jsonParser &json) {
451  json = jsonParser::object();
452  json["real"] = value.real();
453  json["imag"] = value.imag();
454  return json;
455  }
456 
458  template<typename T>
459  void from_json(std::complex<T> &value, const jsonParser &json) {
460  try {
461  value = std::complex<T>(json["real"].get<T>(), json["imag"].get<T>());
462  }
463  catch(...) {
465  throw;
466  }
467  }
468 
469 
471  template<typename Key, typename T>
472  jsonParser &to_json(const std::pair<Key, T> &value, jsonParser &json);
473 
475  template<typename Key, typename T>
476  void from_json(std::pair<Key, T> &value, const jsonParser &json);
477 
485  template<typename ReturnType>
487 
489  static ReturnType from_json(const jsonParser &json) {
490  return CASM::from_json<ReturnType>(json);
491  }
492  };
493 
494 
496  template<typename T>
497  T from_json(const jsonParser &json) {
498  T value;
499  from_json(value, json);
500  return value;
501  }
502 
503 
505  boost::filesystem::path find_diff(const jsonParser &A, const jsonParser &B, boost::filesystem::path diff = boost::filesystem::path());
506 
508  boost::filesystem::path find_diff(const jsonParser &A, const jsonParser &B, double tol, boost::filesystem::path diff = boost::filesystem::path());
509 
510 
514  template<bool IsConst>
515  class jsonParserIterator {
516 
517  public:
518 
519  typedef std::forward_iterator_tag iterator_category;
520  typedef typename std::conditional<IsConst, json_spirit::mObject::const_iterator, json_spirit::mObject::iterator>::type object_iterator;
521  typedef typename std::conditional<IsConst, json_spirit::mArray::const_iterator, json_spirit::mArray::iterator>::type array_iterator;
522  typedef int difference_type;
523  typedef typename std::conditional<IsConst, const jsonParser, jsonParser>::type value_type;
524  typedef value_type &reference;
525  typedef value_type *pointer;
526 
527 
529 
531  : parser(iter.parser), type(iter.type), obj_iter(iter.obj_iter), array_iter(iter.array_iter), val_iter(iter.val_iter) {
532  }
533 
535  swap(*this, iter);
536  return *this;
537  }
538 
539  jsonParserIterator(pointer j, const object_iterator &iter)
540  : parser(j), type(json_spirit::obj_type), obj_iter(iter) {
541  }
542 
543  jsonParserIterator(pointer j, const array_iterator &iter)
544  : parser(j), type(json_spirit::array_type), array_iter(iter) {
545  }
546 
547  jsonParserIterator(pointer j, const int &iter)
548  : parser(j), type(json_spirit::null_type), val_iter(iter) {
549  }
550 
551  reference operator*() {
552  if(type == json_spirit::obj_type)
553  return (reference) obj_iter->second;
554  else if(type == json_spirit::array_type)
555  return (reference) * array_iter;
556  else
557  return *parser;
558  }
559 
560  pointer operator->() {
561  if(type == json_spirit::obj_type)
562  return (pointer) &obj_iter->second;
563  else if(type == json_spirit::array_type)
564  return (pointer) & (*array_iter);
565  else
566  return parser;
567  }
568 
569 
570  bool operator==(const jsonParserIterator &iter) {
571  if(parser != iter.parser)
572  return false;
573 
574  if(type == json_spirit::obj_type)
575  return obj_iter == iter.obj_iter;
576  else if(type == json_spirit::array_type)
577  return array_iter == iter.array_iter;
578  else
579  return true;
580  }
581 
582  bool operator!=(const jsonParserIterator &iter) {
583  return !(*this == iter);
584  }
585 
587  if(type == json_spirit::obj_type) {
588  ++obj_iter;
589  return *this;
590  }
591  else if(type == json_spirit::array_type) {
592  ++array_iter;
593  return *this;
594  }
595  else {
596  ++val_iter;
597  return *this;
598  }
599  }
600 
602 
603  jsonParserIterator cp(*this);
604 
605  if(type == json_spirit::obj_type) {
606  ++obj_iter;
607  return cp;
608  }
609  else if(type == json_spirit::array_type) {
610  ++array_iter;
611  return cp;
612  }
613  else {
614  ++val_iter;
615  return cp;
616  }
617  }
618 
620  if(type == json_spirit::obj_type) {
621  --obj_iter;
622  return *this;
623  }
624  else if(type == json_spirit::array_type) {
625  --array_iter;
626  return *this;
627  }
628  else {
629  --val_iter;
630  return *this;
631  }
632  }
633 
635 
636  jsonParserIterator cp(*this);
637 
638  if(type == json_spirit::obj_type) {
639  --obj_iter;
640  return cp;
641  }
642  else if(type == json_spirit::array_type) {
643  --array_iter;
644  return cp;
645  }
646  else {
647  --val_iter;
648  return cp;
649  }
650  }
651 
653  if(type == json_spirit::obj_type)
655  else if(type == json_spirit::array_type)
657  else
659  }
660 
662  std::string name() {
663  if(type == json_spirit::obj_type)
664  return obj_iter->first;
665  else
666  throw std::runtime_error("Calling 'name' on non-object jsonParserIterator");
667  }
668 
670  using std::swap;
671 
672  std::swap(a.parser, b.parser);
673  swap(a.type, b.type);
674  swap(a.obj_iter, b.obj_iter);
675  swap(a.array_iter, b.array_iter);
676  swap(a.val_iter, b.val_iter);
677  }
678 
679 
680  private:
681 
682  pointer parser;
683 
684  json_spirit::Value_type type;
685 
686  object_iterator obj_iter;
687 
688  array_iterator array_iter;
689 
690  int val_iter;
691 
692  };
693 
695  template<typename T>
697  try {
698  jsonParser json;
699  get_array().push_back(to_json(value, json));
700  return *this;
701  }
702  catch(...) {
704  throw;
705  }
706  }
707 
728  template<typename T, typename...Args>
729  T jsonParser::get(Args... args) const {
730  return jsonConstructor<T>::from_json(*this, args...);
731  }
732 
733  template<typename T, typename...Args>
734  void jsonParser::get(T &t, Args... args) const {
735  from_json(t, *this, args...);
736  }
737 
738 
739  template<typename T, typename...Args>
740  bool jsonParser::get_if(T &t, const std::string &key, Args... args) const {
741  if(find(key) != cend()) {
742  from_json(t, (*this)[key], args...);
743  return true;
744  }
745  return false;
746  }
747 
748  template<typename T, typename...Args>
749  bool jsonParser::get_else(T &t, const std::string &key, const T &default_value, Args... args) const {
750  if(find(key) != cend()) {
751  from_json(t, (*this)[key], args...);
752  return true;
753  }
754 
755  t = default_value;
756  return false;
757  }
758 
760  template <typename T>
761  jsonParser &jsonParser::put(const T &value) {
762  return to_json(value, *this);
763  }
764 
766  template<typename Iterator>
768  Iterator end) {
769  *this = object();
770  for(auto it = begin; it != end; ++it) {
771  to_json(it->second, (*this)[it->first]);
772  }
773  return *this;
774  }
775 
777  template<typename T>
779  *this = array();
780  for(auto i = 0; i < N; ++i) {
781  push_back(t);
782  }
783  return *this;
784  }
785 
787  template<typename Iterator>
789  Iterator begin,
790  Iterator end,
792 
793  *this = array();
794  for(auto it = begin; it != end; ++it) {
795  push_back(*it);
796  }
797  return *this;
798  }
799 
801  template <typename T>
803  return to_json(value, *this);
804  }
805 
807  template<typename Key, typename T>
808  jsonParser &to_json(const std::pair<Key, T> &value, jsonParser &json) {
809  json = jsonParser::object();
810  return json[value.first] = value.second;
811  }
812 
814  template<typename Key, typename T>
815  void from_json(std::pair<Key, T> &value, const jsonParser &json) {
816  auto it = json.begin();
817  value = std::make_pair<Key, T>(it.name(), *it);
818  }
819 
821 }
822 
823 #endif
jsonParser & operator[](const std::string &name)
Definition: jsonParser.cc:290
static jsonParser null()
Returns a null JSON value.
Definition: jsonParser.hh:371
bool operator==(const jsonParserIterator &iter)
Definition: jsonParser.hh:570
size_type size() const
Returns array size if *this is a JSON array, object size if *this is a JSON object, 1 otherwise.
Definition: jsonParser.cc:430
jsonParser()
Create a new empty jsonParser.
Definition: jsonParser.hh:89
bool is_int() const
Check if int type.
Definition: jsonParser.cc:261
std::conditional< IsConst, json_spirit::mArray::const_iterator, json_spirit::mArray::iterator >::type array_iterator
Definition: jsonParser.hh:521
jsonParserIterator operator--(int)
Definition: jsonParser.hh:634
array_iterator array_iter
Definition: jsonParser.hh:688
void from_json(ClexDescription &desc, const jsonParser &json)
iterator end()
Returns iterator to end of JSON object or JSON array.
Definition: jsonParser.cc:465
boost::filesystem::path find_diff(const jsonParser &A, const jsonParser &B, boost::filesystem::path diff=boost::filesystem::path())
Return the location at which jsonParser 'A' != 'B' as a boost::filesystem::path.
Definition: jsonParser.cc:380
jsonParserIterator & operator=(jsonParserIterator iter)
Definition: jsonParser.hh:534
void write(const std::string &file_name, unsigned int indent=2, unsigned int prec=12) const
Write json to file.
Definition: jsonParser.cc:191
bool get_if(T &t, const std::string &key, Args...args) const
Definition: jsonParser.hh:740
std::conditional< IsConst, json_spirit::mObject::const_iterator, json_spirit::mObject::iterator >::type object_iterator
Definition: jsonParser.hh:520
jsonParser & to_json(const ClexDescription &desc, jsonParser &json)
jsonParser & operator=(const json_spirit::mValue &value)
Definition: jsonParser.hh:378
jsonParserIterator< true > const_iterator
Definition: jsonParser.hh:84
jsonParser & at(const fs::path &path)
Definition: jsonParser.cc:321
jsonParser(const T &t)
Definition: jsonParser.hh:104
bool read(std::istream &stream)
Reads json from the stream.
Definition: jsonParser.cc:165
jsonParserIterator(pointer j, const int &iter)
Definition: jsonParser.hh:547
Main CASM namespace.
Definition: complete.cpp:8
iterator begin()
Returns const_iterator to beginning of JSON object or JSON array.
Definition: jsonParser.cc:440
const_iterator cend() const
Returns const_iterator to end of JSON object or JSON array.
Definition: jsonParser.cc:480
static jsonParser parse(std::istream &stream)
Construct a jsonParser from a stream containing JSON data.
Definition: jsonParser.hh:324
object_iterator obj_iter
Definition: jsonParser.hh:686
T get(Args...args) const
Get data from json, using one of several alternatives.
Definition: jsonParser.hh:729
jsonParser & operator=(const T &value)
Puts data of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined...
Definition: jsonParser.hh:802
static jsonParser object(Iterator begin, Iterator end)
Puts new JSON object, from iterators over a range of values of type std::pair
Definition: jsonParser.hh:336
bool is_obj() const
Check if object type.
Definition: jsonParser.cc:276
void print(std::ostream &stream, unsigned int indent=2, unsigned int prec=12) const
Print json to stream.
Definition: jsonParser.cc:185
jsonParserIterator(pointer j, const array_iterator &iter)
Definition: jsonParser.hh:543
void swap(ConfigDoF &A, ConfigDoF &B)
Definition: ConfigDoF.cc:195
double tol
jsonParserIterator(const jsonParserIterator &iter)
Definition: jsonParser.hh:530
jsonParser & put_null()
Puts 'null' JSON value.
Definition: jsonParser.hh:305
long int from_json< long int >(const jsonParser &json)
Definition: jsonParser.cc:81
unsigned int from_json< unsigned int >(const jsonParser &json)
Definition: jsonParser.cc:76
bool is_null() const
Check if null type.
Definition: jsonParser.cc:251
size_type erase(const std::string &name)
Erase key:value pair from an object.
Definition: jsonParser.cc:506
std::ostream & operator<<(std::ostream &_stream, const FormattedPrintable &_formatted)
bool operator==(const UnitCellCoord &A, const UnitCellCoord &B)
Compare UnitCellCoord.
json_spirit::mObject::size_type size_type
Definition: jsonParser.hh:82
bool is_string() const
Check if string.
Definition: jsonParser.cc:271
json_spirit::Value_type type
Definition: jsonParser.hh:684
bool operator!=(const jsonParserIterator &iter)
Definition: jsonParser.hh:582
bool get_else(T &t, const std::string &key, const T &default_value, Args...args) const
Definition: jsonParser.hh:749
friend void swap(jsonParserIterator &a, jsonParserIterator &b)
Definition: jsonParser.hh:669
static ReturnType from_json(const jsonParser &json)
Default from_json is equivalent to.
Definition: jsonParser.hh:489
bool is_bool() const
Check if bool type.
Definition: jsonParser.cc:256
jsonParserIterator & operator--()
Definition: jsonParser.hh:619
std::istream & operator>>(std::istream &_in, std::vector< T > &vec)
int from_json< int >(const jsonParser &json)
Definition: jsonParser.cc:71
iterator find(const std::string &name)
Return iterator to JSON object value with 'name'.
Definition: jsonParser.cc:490
Helper struct for constructing objects that need additional data.
Definition: jsonParser.hh:486
static jsonParser array(Iterator begin, Iterator end, typename CASM_TMP::enable_if_iterator< Iterator >::type *=nullptr)
Puts new JSON array, from iterators.
Definition: jsonParser.hh:362
jsonParser & put_obj()
Puts new empty JSON object.
Definition: jsonParser.hh:276
std::forward_iterator_tag iterator_category
Definition: jsonParser.hh:519
jsonParserIterator< false > iterator
Definition: jsonParser.hh:83
static jsonParser parse(const std::string &str)
Construct a jsonParser from a string containing JSON data.
Definition: jsonParser.hh:312
jsonParser & put(const T &value)
Puts data of any type T for which 'jsonParser& to_json( const T &value, jsonParser &json)' is defined (same as 'o...
Definition: jsonParser.hh:761
double from_json< double >(const jsonParser &json)
Definition: jsonParser.cc:91
bool is_number() const
Check if number type (not including int)
Definition: jsonParser.cc:266
static jsonParser array(size_type N)
Returns an empty json array.
Definition: jsonParser.hh:348
bool almost_equal(const jsonParser &B, double tol) const
Definition: jsonParser.cc:211
jsonParser & push_back(const T &value)
Puts new valued element at end of array of any type T for which 'jsonParser& to_json( const T &value...
Definition: jsonParser.hh:696
bool contains(const std::string &name) const
Return true if JSON object contains 'name'.
Definition: jsonParser.cc:500
jsonParserIterator(pointer j, const object_iterator &iter)
Definition: jsonParser.hh:539
std::enable_if< is_iterator< T >::type::value, void > enable_if_iterator
Template alias to enable a template function via SFINAE for any iterator.
Definition: CASM_TMP.hh:53
std::string name()
When iterating over a JSON object, returns the 'name' of the 'name':value pair the iterator is pointi...
Definition: jsonParser.hh:662
static jsonParser parse(const fs::path &path)
Construct a jsonParser from a file containing JSON data.
Definition: jsonParser.hh:319
jsonParser & put_array(size_type N)
Puts new JSON array.
Definition: jsonParser.hh:290
bool is_array() const
Check if array type.
Definition: jsonParser.cc:281
jsonParserIterator & operator++()
Definition: jsonParser.hh:586
static jsonParser object()
Returns an empty json object.
Definition: jsonParser.hh:329
const_iterator cbegin() const
Returns const_iterator to beginning of JSON object or JSON array.
Definition: jsonParser.cc:455
jsonParser from_json< jsonParser >(const jsonParser &json)
Definition: jsonParser.cc:103
bool operator!=(const jsonParser &json) const
Definition: jsonParser.hh:157
bool from_json< bool >(const jsonParser &json)
Definition: jsonParser.cc:66
jsonParser & put_array()
Puts new empty JSON array.
Definition: jsonParser.hh:285
static jsonParser array()
Returns an empty json array.
Definition: jsonParser.hh:342
static jsonParser array(size_type N, const T &t)
Puts new JSON array, using the same value.
Definition: jsonParser.hh:355
std::conditional< IsConst, const jsonParser, jsonParser >::type value_type
Definition: jsonParser.hh:523
unsigned long int from_json< unsigned long int >(const jsonParser &json)
Definition: jsonParser.cc:86
jsonParserIterator operator++(int)
Definition: jsonParser.hh:601