Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Namespace uint8_t from the C++ stdlib #510

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@ Please note that setting the exception bit for `failbit` is inappropriate for th

#### Read from iterator range

You can also read JSON from an iterator range; that is, from any container accessible by iterators whose content is stored as contiguous byte sequence, for instance a `std::vector<uint8_t>`:
You can also read JSON from an iterator range; that is, from any container accessible by iterators whose content is stored as contiguous byte sequence, for instance a `std::vector<std::uint8_t>`:

```cpp
std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
json j = json::parse(v.begin(), v.end());
```

You may leave the iterators for the range [begin, end):

```cpp
std::vector<uint8_t> v = {'t', 'r', 'u', 'e'};
std::vector<std::uint8_t> v = {'t', 'r', 'u', 'e'};
json j = json::parse(v);
```

Expand Down Expand Up @@ -682,15 +682,15 @@ Though JSON is a ubiquitous data format, it is not a very compact format suitabl
json j = R"({"compact": true, "schema": 0})"_json;

// serialize to CBOR
std::vector<uint8_t> v_cbor = json::to_cbor(j);
std::vector<std::uint8_t> v_cbor = json::to_cbor(j);

// 0xa2, 0x67, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xf5, 0x66, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00

// roundtrip
json j_from_cbor = json::from_cbor(v_cbor);

// serialize to MessagePack
std::vector<uint8_t> v_msgpack = json::to_msgpack(j);
std::vector<std::uint8_t> v_msgpack = json::to_msgpack(j);

// 0x82, 0xa7, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x63, 0x74, 0xc3, 0xa6, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x00

Expand Down