Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
3bef1a50
Commit
3bef1a50
authored
Jan 04, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed "toString()" to "to_string()"
parent
f63ff772
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
14 deletions
+14
-14
README.md
README.md
+1
-1
json.cc
src/json.cc
+3
-3
json.h
src/json.h
+3
-3
json_unit.cc
test/json_unit.cc
+7
-7
No files found.
README.md
View file @
3bef1a50
...
@@ -116,7 +116,7 @@ You can also get a string representation (serialize):
...
@@ -116,7 +116,7 @@ You can also get a string representation (serialize):
```
cpp
```
cpp
// explicit conversion to string
// explicit conversion to string
std
::
string
s
=
j
.
to
S
tring
();
std
::
string
s
=
j
.
to
_s
tring
();
```
```
The value of s could be
`{"pi": 3.141, "happy": true}`
, but the order of the entries in the object is not fixed.
The value of s could be
`{"pi": 3.141, "happy": true}`
, but the order of the entries in the object is not fixed.
...
...
src/json.cc
View file @
3bef1a50
...
@@ -477,7 +477,7 @@ json::operator object_t() const
...
@@ -477,7 +477,7 @@ json::operator object_t() const
return
get
<
object_t
>
();
return
get
<
object_t
>
();
}
}
const
std
::
string
json
::
to
S
tring
()
const
noexcept
const
std
::
string
json
::
to
_s
tring
()
const
noexcept
{
{
switch
(
_type
)
switch
(
_type
)
{
{
...
@@ -511,7 +511,7 @@ const std::string json::toString() const noexcept
...
@@ -511,7 +511,7 @@ const std::string json::toString() const noexcept
{
{
result
+=
", "
;
result
+=
", "
;
}
}
result
+=
i
->
to
S
tring
();
result
+=
i
->
to
_s
tring
();
}
}
return
"["
+
result
+
"]"
;
return
"["
+
result
+
"]"
;
...
@@ -527,7 +527,7 @@ const std::string json::toString() const noexcept
...
@@ -527,7 +527,7 @@ const std::string json::toString() const noexcept
{
{
result
+=
", "
;
result
+=
", "
;
}
}
result
+=
"
\"
"
+
i
->
first
+
"
\"
: "
+
i
->
second
.
to
S
tring
();
result
+=
"
\"
"
+
i
->
first
+
"
\"
: "
+
i
->
second
.
to
_s
tring
();
}
}
return
"{"
+
result
+
"}"
;
return
"{"
+
result
+
"}"
;
...
...
src/json.h
View file @
3bef1a50
...
@@ -181,13 +181,13 @@ class json
...
@@ -181,13 +181,13 @@ class json
/// write to stream
/// write to stream
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
o
,
const
json
&
j
)
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
o
,
const
json
&
j
)
{
{
o
<<
j
.
to
S
tring
();
o
<<
j
.
to
_s
tring
();
return
o
;
return
o
;
}
}
/// write to stream
/// write to stream
friend
std
::
ostream
&
operator
>>
(
const
json
&
j
,
std
::
ostream
&
o
)
friend
std
::
ostream
&
operator
>>
(
const
json
&
j
,
std
::
ostream
&
o
)
{
{
o
<<
j
.
to
S
tring
();
o
<<
j
.
to
_s
tring
();
return
o
;
return
o
;
}
}
...
@@ -205,7 +205,7 @@ class json
...
@@ -205,7 +205,7 @@ class json
}
}
/// explicit conversion to string representation (C++ style)
/// explicit conversion to string representation (C++ style)
const
std
::
string
to
S
tring
()
const
noexcept
;
const
std
::
string
to
_s
tring
()
const
noexcept
;
/// add an object/array to an array
/// add an object/array to an array
json
&
operator
+=
(
const
json
&
);
json
&
operator
+=
(
const
json
&
);
...
...
test/json_unit.cc
View file @
3bef1a50
...
@@ -15,7 +15,7 @@ TEST_CASE("array")
...
@@ -15,7 +15,7 @@ TEST_CASE("array")
const
json
j_const
(
j
);
const
json
j_const
(
j
);
// string representation of default value
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"[]"
);
CHECK
(
j
.
to
_s
tring
()
==
"[]"
);
// iterators
// iterators
CHECK
(
j
.
begin
()
!=
j
.
end
());
CHECK
(
j
.
begin
()
!=
j
.
end
());
...
@@ -303,7 +303,7 @@ TEST_CASE("object")
...
@@ -303,7 +303,7 @@ TEST_CASE("object")
const
json
j_const
=
j
;
const
json
j_const
=
j
;
// string representation of default value
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"{}"
);
CHECK
(
j
.
to
_s
tring
()
==
"{}"
);
// iterators
// iterators
CHECK
(
j
.
begin
()
!=
j
.
end
());
CHECK
(
j
.
begin
()
!=
j
.
end
());
...
@@ -683,7 +683,7 @@ TEST_CASE("null")
...
@@ -683,7 +683,7 @@ TEST_CASE("null")
CHECK
(
j
.
type
()
==
json
::
value_type
::
null
);
CHECK
(
j
.
type
()
==
json
::
value_type
::
null
);
// string representation of default value
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"null"
);
CHECK
(
j
.
to
_s
tring
()
==
"null"
);
// iterators
// iterators
CHECK
(
j
.
begin
()
!=
j
.
end
());
CHECK
(
j
.
begin
()
!=
j
.
end
());
...
@@ -753,7 +753,7 @@ TEST_CASE("string")
...
@@ -753,7 +753,7 @@ TEST_CASE("string")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"
\"\"
"
);
CHECK
(
j
.
to
_s
tring
()
==
"
\"\"
"
);
// container members
// container members
CHECK
(
j
.
size
()
==
1
);
CHECK
(
j
.
size
()
==
1
);
...
@@ -835,7 +835,7 @@ TEST_CASE("boolean")
...
@@ -835,7 +835,7 @@ TEST_CASE("boolean")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"false"
);
CHECK
(
j
.
to
_s
tring
()
==
"false"
);
// container members
// container members
CHECK
(
j
.
size
()
==
1
);
CHECK
(
j
.
size
()
==
1
);
...
@@ -914,7 +914,7 @@ TEST_CASE("number (int)")
...
@@ -914,7 +914,7 @@ TEST_CASE("number (int)")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"0"
);
CHECK
(
j
.
to
_s
tring
()
==
"0"
);
// container members
// container members
CHECK
(
j
.
size
()
==
1
);
CHECK
(
j
.
size
()
==
1
);
...
@@ -1000,7 +1000,7 @@ TEST_CASE("number (float)")
...
@@ -1000,7 +1000,7 @@ TEST_CASE("number (float)")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"0.000000"
);
CHECK
(
j
.
to
_s
tring
()
==
"0.000000"
);
// container members
// container members
CHECK
(
j
.
size
()
==
1
);
CHECK
(
j
.
size
()
==
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment