@@ -40,6 +40,8 @@ in your source code to use JSON Pointer.
40
40
#include < iostream>
41
41
#include < array>
42
42
43
+ using namespace format ;
44
+
43
45
// Create a JSON pointer object
44
46
json_pointer jp (L"/foo/1");
45
47
@@ -57,9 +59,9 @@ json j = L"{ \"foo\": [\"bar\", \"baz\"],\
57
59
// Get the value the pointer refers to
58
60
value & v = jp.value (j);
59
61
60
- std::wcout << v.as<const wchar_t * >() << std::endl;
62
+ std::wcout << v.as<const wchar_t * > () << std::endl;
61
63
// ouput: baz
62
-
64
+
63
65
// Create an array of JSON pointers
64
66
std::array<format::json_pointer, 13> jp_list = {
65
67
// pointer: // output:
@@ -81,16 +83,16 @@ std::array<format::json_pointer, 13> jp_list = {
81
83
for (auto& jp : jp_list)
82
84
{
83
85
try {
84
- // Look for the value in the JSON object
85
- format:: json::value & v = jp.value (j);
86
-
86
+ // Get the value the pointer refers to
87
+ json::value & v = jp.value (j);
88
+
87
89
// If value is not found, object type is undefined
88
- if (v.type () == format::json:: value::undefined_t)
90
+ if (v.type () == value::undefined_t)
89
91
std::wcout << "Value not found" << std::endl;
90
92
else
91
93
std::wcout << v.stringify () << std::endl;
92
-
93
- } catch (format:: json_pointer_error & e) {
94
+
95
+ } catch (json_pointer_error & e) {
94
96
// Invalid pointer syntax or
95
97
// a pointer that references a nonexistent value
96
98
std::wcerr << e.what () << std::endl;
0 commit comments