@@ -38,7 +38,7 @@ Now let's serialize `person` to `json` string.
3838
3939 person p = { "tom", 28 };
4040
41- iguana::string_stream ss;
41+ iguana::string_stream ss; // here use std::string is also ok
4242 iguana::to_json(p, ss);
4343
4444 std::cout << ss.str() << std::endl;
@@ -49,11 +49,27 @@ Serializing person to `json` string is also very simple, just need to call `to_j
4949
5050How about deserialization of ` json ` ? Look at the follow example.
5151
52- const char * json = "{ \"name\" : \"tom\", \"age\" : 28}";
52+ std::string json = "{ \"name\" : \"tom\", \"age\" : 28}";
5353
5454 person p;
5555 iguana::from_json(p, json);
56- It's as simple as serialization, just need to call ` from_json ` method.
56+ It's as simple as serialization, just need to call ` from_json ` method.
57+
58+ You can also use parse interface to do dom parsing:
59+ ``` c++
60+ std::string_view str = R"( false)" ;
61+ iguana::jvalue val;
62+ iguana::parse (val, str.begin(), str.end());
63+
64+ std::error_code ec;
65+ auto b = val.get<bool>(ec);
66+ CHECK(!ec);
67+ CHECK(!b);
68+
69+ // or
70+ b = val.get<bool>(); // this interface maybe throw exception
71+ CHECK(!b);
72+ ```
5773
5874### Serialization of xml
5975Serialization of `xml` is similar to `json`. The first step is also defining meta data as above. This is a complete example.
@@ -107,7 +123,7 @@ Then call the simple interface:
107123 iguana::to_json(composit, ss);
108124 std::cout << ss.str() << std::endl;
109125
110- const char* str_comp = R"({"a":1, "b":["tom", "jack"], "c":3, "d":{"2":3,"5":6},"e":{"3":4},"f":5.3,"g":[{"id":1},{"id":2}])";
126+ std::string str_comp = R"({"a":1, "b":["tom", "jack"], "c":3, "d":{"2":3,"5":6},"e":{"3":4},"f":5.3,"g":[{"id":1},{"id":2}])";
111127 composit_t comp;
112128 iguana::from_json(comp, str_comp);
113129
0 commit comments