Skip to content

Commit dfb01ef

Browse files
committed
json_options tab example
1 parent 59bbbdb commit dfb01ef

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

doc/ref/corelib/basic_json_options.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ Output:
495495
(2) {"first":1,"second":2}
496496
```
497497

498-
### Parse integer with lossless_bignum
498+
#### Parse integer with lossless_bignum
499499

500500
```cpp
501501
#include <jsoncons/json.hpp>
@@ -534,7 +534,7 @@ Output:
534534
(2) {"a":1.2345678901234568e+29}
535535
```
536536

537-
### Parse floating point with lossless_bignum
537+
#### Parse floating point with lossless_bignum
538538

539539
```cpp
540540
#include <jsoncons/json.hpp>
@@ -575,3 +575,28 @@ Output:
575575
(2) inf
576576
(3) {"a":null}
577577
```
578+
579+
#### Indent with tabs
580+
581+
```cpp
582+
#include <jsoncons/json.hpp>
583+
#include <cassert>
584+
585+
int main()
586+
{
587+
jsoncons::json j{jsoncons::json_array_arg};
588+
j.push_back(jsoncons::json{jsoncons::json_object_arg});
589+
j[0]["foo"] = 1;
590+
591+
auto options = jsoncons::json_options{}
592+
.indent_char('\t')
593+
.indent_size(1);
594+
595+
std::string buffer;
596+
j.dump_pretty(buffer, options);
597+
598+
std::string expected = "[\n\t{\n\t\t\"foo\": 1\n\t}\n]";
599+
assert(expected == buffer);
600+
}
601+
```
602+

0 commit comments

Comments
 (0)