-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson-object.cc
44 lines (37 loc) · 993 Bytes
/
json-object.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream> // for cout,cerr...
#include "json-object.h"
#include "json-value.h"
namespace json {
json_object::json_object() : _Impl_object()
{
}
json_object::json_object(const json_object &rvalue) :
_Impl_object(rvalue._Impl_object)
{
}
json_object::json_object(json_object &&rvalue) :
_Impl_object(std::move(rvalue._Impl_object))
{
}
json_object::json_object(const json_object::value_type &var) :
_Impl_object()
{
if (var.typeof() == "JSON_OBJECT") {
*this = var.value._M_json_object;
} else {
std::cerr << "Can't convert '" << var
<< "' from `" << var.typeof() << "` to `JSON_OBJECT`\n";
}
}
std::ostream &operator<<(std::ostream &out, const json_object &rvalue)
{
out << '{';
for (auto it = rvalue.begin(); it != rvalue.end(); it++) {
out << (*it).first << ':' << (*it).second;
if (std::next(it) != rvalue.end())
out << ',';
}
out << '}';
return out;
}
}