Lines Matching refs:JsonValue

8 …erate an instance of `JsonValue` from JSON text or string. You need to use a series of instance cr…
10 (1) You can create a `JsonValue` instance by:
15 use ylong_json::JsonValue;
18 // You can use `from_str` to try to generate a `JsonValue` instance from
22 let json_value = JsonValue::from_str(str);
25 // You can use `from_text` to generate a `JsonValue` instance from
29 let json_value = JsonValue::from_text(text);
33 // try to generate a `JsonValue` instance.
36 let json_value = JsonValue::from_file(path);
40 // that implements io::Read and try to generate a `JsonValue` instance.
43 let json_value = JsonValue::from_reader(&mut reader);
46 Once the `JsonValue` instance has been successfully created, you can attempt to read and modify the…
83JsonValue` instance is successfully generated, you can use a subscript to find the corresponding k…
89 use ylong_json::JsonValue;
100 // Creates a JsonValue instance from the example string, the syntax is
102 let json_value = JsonValue::from_str(JSON_TEXT).unwrap();
106 let value: &JsonValue = &json_value["key"];
110 let array_item: &JsonValue = &json_value["array"][0];
113 // `&JsonValue::Null` will be returned.
114 let no_such_key: &JsonValue = &json_value["no_such_key"];
117 // `&JsonValue::Null` will also be returned.
118 let no_such_index: &JsonValue = &json_value["array"][100];
120 // If you use a subscript to visit `JsonValue` types other than Object and Array,
121 // `&JsonValue::Null` will also be returned.
122 let invalid_index: &JsonValue = &json_value["key"]["invalid"];
123 let invalid_index: &JsonValue = &json_value["key"][0];
126 You can also use the same method to obtain a mutable reference to `JsonValue`.
129 use ylong_json::JsonValue;
140 // Creates a JsonValue instance from the example string, the syntax is
143 let mut json_value = JsonValue::from_str(JSON_TEXT).unwrap();
146 // In the libraty, many primitive types implement conversion from themselves to JsonValue,
147 // so they can be converted to `JsonValue` by using `into()` method.
165 // then the key will be inserted in the table with the corresponding value JsonValue::Null,
178 // subscript exceeds the Array length, then a `JsonValue::Null` will be added at
222 (1) When you have a JsonValue instance, you can convert it to text and output it to a specified loc…
225 use ylong_json::JsonValue;
227 fn output_json_text(json_value: JsonValue) {