57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#ifndef __JString_h__
|
|
#define __JString_h__
|
|
|
|
#include "MString.h"
|
|
#include <iostream>
|
|
#include <sstream>
|
|
|
|
namespace coreutils {
|
|
|
|
///
|
|
/// Use the JString object when you need a JSON interface to C++. JString uses
|
|
/// an MString to store a JSON string representing the object(s) contained.
|
|
/// The [] operator is overriden from the ZString and provides a method to
|
|
/// access the objects elements using a named path as the index to the items.
|
|
///
|
|
|
|
class JString : public MString {
|
|
|
|
public:
|
|
|
|
JString();
|
|
JString(const char *data);
|
|
|
|
void set(ZString path, const char *value);
|
|
|
|
///
|
|
/// Use the find method to look through an object for member specified by
|
|
/// the key in parameter 1. The cursor must be pointing to the { character
|
|
/// that begins the object's list.
|
|
///
|
|
|
|
ZString find(ZString path);
|
|
|
|
void operator=(ZString &value);
|
|
JString& operator=(const char *value);
|
|
|
|
// ZString operator[](const char *path);
|
|
JString& operator[](const char *path);
|
|
// operator const ZString () const {
|
|
// return *this;
|
|
// }
|
|
|
|
// MString & operator[](ZString &key);
|
|
|
|
// MString & operator[](std::string key);
|
|
|
|
private:
|
|
bool locate(ZString path);
|
|
bool notfirst;
|
|
MString path;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|