索引赋值不太好实现,直接添加更好

This commit is contained in:
nnhy 2016-10-27 12:31:49 +00:00
parent 7e19062248
commit d691eca815
1 changed files with 11 additions and 4 deletions

View File

@ -79,11 +79,16 @@ static void TestWrite()
String rs; String rs;
json.SetOut(rs); json.SetOut(rs);
json["id"] = 3141; /*json["id"] = 3141;
json["name"] = "Smart \" Stone"; json["name"] = "Smart \" Stone";
json["enable"] = "true"; json["enable"] = "true";
json["noval"] = nullptr; json["noval"] = nullptr;
json["score"] = 3.14159; json["score"] = 3.14159;*/
json.Add("id", 3141);
json.Add("name", "Smart \" Stone");
json.Add("enable", "true");
json.Add("noval", nullptr);
json.Add("score", 3.14159);
auto arr = json["array"]; auto arr = json["array"];
/*arr[0] = 1; /*arr[0] = 1;
@ -92,8 +97,10 @@ static void TestWrite()
arr.Add(1).Add(0).Add(2); arr.Add(1).Add(0).Add(2);
auto ext = json["extend"]; auto ext = json["extend"];
ext["kind"] = "cost"; /*ext["kind"] = "cost";
ext["value"]= 67.89f; ext["value"]= 67.89f;*/
ext.Add("kind", "cost");
ext.Add("value", 67.89f);
//auto rs = json.ToString(); //auto rs = json.ToString();
rs.Show(true); rs.Show(true);