Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "json_builder.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- {
- json::Print(
- json::Document {
- json::Builder {}.StartArray().StartDict().EndDict().Value(1).EndArray().Build() },
- cout);
- }
- cout << endl;
- {
- json::Print(
- json::Document {
- json::Builder {}.StartDict().Key("1").StartArray().EndArray().Key("2").Value(2).EndDict().Build() },
- cout);
- }
- cout << endl;
- {
- try {
- json::Builder{}
- .StartDict()
- .Key("1"s)
- .StartArray()
- .Value(12)
- .EndArray()
- .EndArray()
- .Build();
- }
- catch (std::logic_error const&) {
- puts("Good");
- }
- }
- cout << endl;
- {
- try {
- json::Builder{}
- .StartArray()
- .StartDict()
- .Key("1"s).Value(12)
- .EndDict()
- .EndDict()
- .Build();
- }
- catch (std::logic_error const&) {
- puts("Good");
- }
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement