問題の説明
JsonCppのラッパーを作成しようとしています。私のラッパーは次の機能を持っている必要があります
Parse(const string& input)
GetString(string& output, const string name, bool optional = true)
SetString(const string& value, const string name, bool optional = true)
GetObject(const string& objectName)
ラッパークラスを呼び出しましたParser
class Parser
{
private:
Json::Value mJsonObject;
public:
bool Parse(const string& input);
bool GetString(string& output, const string name, bool optional = true);
bool SetString(const string& value, const string name, bool optional = true);
Parser& GetObject(const string& objectName);
};
私が書きたいコードでは、次のとおりです。
void foo()
{
Parser::GetObject("IN").GetObject("Params").SetString("Param1", "this is json");
}
これを呼び出すことで、次のJSONを作成したい
{
"IN" : {
"Params" : {
"Param1":"this is json"
}
}
}
質問
期待される結果を得るために、どのように実装GetObject
して機能する必要がありますか?SetString