@@ -56,20 +56,24 @@ std::cin >> root;
56
56
// You can also read into a particular sub-value.
57
57
std::cin >> root["subtree"];
58
58
59
- // Get the value of the member of root named 'encoding', return 'UTF-8' if there is no
60
- // such member.
59
+ // Get the value of the member of root named 'encoding',
60
+ // and return 'UTF-8' if there is no such member.
61
61
std::string encoding = root.get("encoding", "UTF-8" ).asString();
62
- // Get the value of the member of root named 'encoding'; return a 'null' value if
62
+
63
+ // Get the value of the member of root named 'plug-ins'; return a 'null' value if
63
64
// there is no such member.
64
65
const Json::Value plugins = root["plug-ins"];
65
- for ( int index = 0; index < plugins.size(); ++index ) // Iterates over the sequence elements.
66
+
67
+ // Iterate over the sequence elements.
68
+ for ( int index = 0; index < plugins.size(); ++index )
66
69
loadPlugIn( plugins[index].asString() );
67
70
71
+ // Try other datatypes. Some are auto-convertible to others.
68
72
foo::setIndentLength( root["indent"].get("length", 3).asInt() );
69
73
foo::setIndentUseSpace( root["indent"].get("use_space", true).asBool() );
70
74
71
- // Since Json::Value has implicit constructor for all value types, it is not
72
- // necessary to explicitly construct the Json::Value object:
75
+ // Since Json::Value has an implicit constructor for all value types, it is not
76
+ // necessary to explicitly construct the Json::Value object.
73
77
root["encoding"] = foo::getCurrentEncoding();
74
78
root["indent"]["length"] = foo::getCurrentIndentLength();
75
79
root["indent"]["use_space"] = foo::getCurrentIndentUseSpace();
0 commit comments