Add Validation section to README.md
This commit is contained in:
parent
17c0849a63
commit
0a45490571
12
README.md
12
README.md
@ -21,6 +21,7 @@
|
|||||||
- [Package Managers](#package-managers)
|
- [Package Managers](#package-managers)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [JSON as first-class data type](#json-as-first-class-data-type)
|
- [JSON as first-class data type](#json-as-first-class-data-type)
|
||||||
|
- [Validation](#validation)
|
||||||
- [Serialization / Deserialization](#serialization--deserialization)
|
- [Serialization / Deserialization](#serialization--deserialization)
|
||||||
- [STL-like access](#stl-like-access)
|
- [STL-like access](#stl-like-access)
|
||||||
- [Conversion from STL containers](#conversion-from-stl-containers)
|
- [Conversion from STL containers](#conversion-from-stl-containers)
|
||||||
@ -257,6 +258,17 @@ json empty_object_explicit = json::object();
|
|||||||
json array_not_object = json::array({ {"currency", "USD"}, {"value", 42.99} });
|
json array_not_object = json::array({ {"currency", "USD"}, {"value", 42.99} });
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Validation
|
||||||
|
|
||||||
|
You can validate a json string using the accept() method:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
bool success = json::accept("Invalid json string");
|
||||||
|
// success is false
|
||||||
|
```
|
||||||
|
|
||||||
|
It is highly recommended to call accept() before parse() when receiving json strings from an untrusted source (a web server for example) as parse() can cause fatal errors when passed malformed json.
|
||||||
|
|
||||||
### Serialization / Deserialization
|
### Serialization / Deserialization
|
||||||
|
|
||||||
#### To/from strings
|
#### To/from strings
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user