#include <jsoncpp/json/json.h>

/*json数据对象类*/
class Json::Value
{
    Value &operator=(const Value &other);       // Value重载了[]和=，因此所有的赋值和获取数据都可以通过
    Value &operator[](const std::string &key);  // 简单的⽅式完成 val["name"] ="xx";
    Value &operator[](const char *key);
    Value removeMember(const char *key);             // 移除元素
    const Value &operator[](ArrayIndex index) const; // val["score"][0]
    Value &append(const Value &value);               // 添加数组元素val["score"].append(88);
    ArrayIndex size() const;                         // 获取数组元素个数 val["score"].size();
    bool isNull();                                   // ⽤于判断是否存在某个字段
    std::string asString() const;                    // 转string string name =
    val["name"].asString();
    const char *asCString() const; // 转char* char *name =
    val["name"].asCString();
    Int asInt() const;     // 转int int age = val["age"].asInt();
    float asFloat() const; // 转float float weight = val["weight"].asFloat();
    bool asBool() const;   // 转 bool bool ok = val["ok"].asBool();
};
/*序列化接口*/
class JSON_API StreamWriter
{
    virtual int write(Value const &root, std::ostream *sout) = 0;
}; 
class JSON_API StreamWriterBuilder : public StreamWriter::Factory
{
    virtual StreamWriter *newStreamWriter() const;
};
/*反序列化接口*/
class JSON_API CharReader
{
    virtual bool parse(char const *beginDoc, char const *endDoc,
                       Value *root, std::string *errs) = 0;
};
class JSON_API CharReaderBuilder : public CharReader::Factory
{
    virtual CharReader *newCharReader() const;
};