@@ -285,41 +285,43 @@ const Json::Array& Json::Value::getArray() const{
285
285
return *_array;
286
286
}
287
287
288
- std::ostream& Json::operator <<(std::ostream& os, const Json::Value& value){
288
+ namespace Json {
289
+ std::ostream& operator <<(std::ostream& os, const Value& value){
289
290
290
- if (value._type == Value::objectType){
291
- assert (value._object != 0 );
292
- os << *(value._object );
293
- return os;
294
- }
291
+ if (value._type == Value::objectType){
292
+ assert (value._object != 0 );
293
+ os << *(value._object );
294
+ return os;
295
+ }
295
296
296
- if (value._type == Value::arrayType){
297
- assert (value._array != 0 );
298
- os << *(value._array );
299
- return os;
300
- }
297
+ if (value._type == Value::arrayType){
298
+ assert (value._array != 0 );
299
+ os << *(value._array );
300
+ return os;
301
+ }
301
302
302
- if (value._type == Value::nullType){
303
- os << " null" ;
304
- return os;
305
- }
303
+ if (value._type == Value::nullType){
304
+ os << " null" ;
305
+ return os;
306
+ }
306
307
307
- if (value._type == Value::booleanType){
308
- if (value)
309
- os << " true" ;
310
- else
311
- os << " false" ;
312
- return os;
313
- }
308
+ if (value._type == Value::booleanType){
309
+ if (value)
310
+ os << " true" ;
311
+ else
312
+ os << " false" ;
313
+ return os;
314
+ }
315
+
316
+ if (value._type == Value::stringType){
317
+ os << " \" " << value._data << " \" " ;
318
+ return os;
319
+ }
314
320
315
- if (value._type == Value::stringType){
316
- os << " \" " << value._data << " \" " ;
321
+ assert (value._type == Value::numberType);
322
+ os << value._data ;
317
323
return os;
318
324
}
319
-
320
- assert (value._type == Value::numberType);
321
- os << value._data ;
322
- return os;
323
325
}
324
326
325
327
// Set this value as a boolean.
@@ -852,17 +854,19 @@ bool Json::Object::operator==(const Object& o) const {
852
854
}
853
855
854
856
// Output in Json format
855
- ostream& Json::operator <<(ostream& os, const Json::Object& obj){
856
- os << " {" ;
857
- for (std::map< Key, Value >::const_iterator it = obj._memberMap .begin (); it != obj._memberMap .end (); ){
858
- os << " \" " << it->first << " \" :" << it->second ;
859
- ++it;
860
- if (it != obj._memberMap .end ())
861
- os << " ," ;
862
- }
863
- os << " }" ;
857
+ namespace Json {
858
+ std::ostream& operator <<(std::ostream& os, const Object& obj){
859
+ os << " {" ;
860
+ for (std::map< Key, Value >::const_iterator it = obj._memberMap .begin (); it != obj._memberMap .end (); ){
861
+ os << " \" " << it->first << " \" :" << it->second ;
862
+ ++it;
863
+ if (it != obj._memberMap .end ())
864
+ os << " ," ;
865
+ }
866
+ os << " }" ;
864
867
865
- return os;
868
+ return os;
869
+ }
866
870
}
867
871
868
872
/* ------------------- Json Array ------------------*/
@@ -941,20 +945,22 @@ bool Json::Array::operator==(const Array& a) const {
941
945
}
942
946
943
947
// Output in Json pretty format
944
- ostream& Json::operator <<(ostream& os, const Json::Array& array){
948
+ namespace Json {
949
+ std::ostream& operator <<(std::ostream& os, const Array& array){
945
950
946
- os << " [" ;
951
+ os << " [" ;
947
952
948
- list<Value>::const_iterator it = array._elementList .begin ();
949
- if (it != array._elementList .end ())
950
- os << *it;
953
+ list<Value>::const_iterator it = array._elementList .begin ();
954
+ if (it != array._elementList .end ())
955
+ os << *it;
951
956
952
- for (++it; it != array._elementList .end (); ++it)
953
- os << " ," << *it;
957
+ for (++it; it != array._elementList .end (); ++it)
958
+ os << " ," << *it;
954
959
955
- os << ' ]' ;
960
+ os << ' ]' ;
956
961
957
- return os;
962
+ return os;
963
+ }
958
964
}
959
965
960
966
// Returns the data in Json Format.
0 commit comments