Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
3bef1a50
J
json
项目概览
畅游知识海洋
/
json
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
json
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3bef1a50
编写于
1月 04, 2015
作者:
N
Niels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
renamed "toString()" to "to_string()"
上级
f63ff772
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
14 addition
and
14 deletion
+14
-14
README.md
README.md
+1
-1
src/json.cc
src/json.cc
+3
-3
src/json.h
src/json.h
+3
-3
test/json_unit.cc
test/json_unit.cc
+7
-7
未找到文件。
README.md
浏览文件 @
3bef1a50
...
...
@@ -116,7 +116,7 @@ You can also get a string representation (serialize):
```
cpp
// 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.
...
...
src/json.cc
浏览文件 @
3bef1a50
...
...
@@ -477,7 +477,7 @@ json::operator object_t() const
return
get
<
object_t
>
();
}
const
std
::
string
json
::
to
S
tring
()
const
noexcept
const
std
::
string
json
::
to
_s
tring
()
const
noexcept
{
switch
(
_type
)
{
...
...
@@ -511,7 +511,7 @@ const std::string json::toString() const noexcept
{
result
+=
", "
;
}
result
+=
i
->
to
S
tring
();
result
+=
i
->
to
_s
tring
();
}
return
"["
+
result
+
"]"
;
...
...
@@ -527,7 +527,7 @@ const std::string json::toString() const noexcept
{
result
+=
", "
;
}
result
+=
"
\"
"
+
i
->
first
+
"
\"
: "
+
i
->
second
.
to
S
tring
();
result
+=
"
\"
"
+
i
->
first
+
"
\"
: "
+
i
->
second
.
to
_s
tring
();
}
return
"{"
+
result
+
"}"
;
...
...
src/json.h
浏览文件 @
3bef1a50
...
...
@@ -181,13 +181,13 @@ class json
/// write to stream
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
o
,
const
json
&
j
)
{
o
<<
j
.
to
S
tring
();
o
<<
j
.
to
_s
tring
();
return
o
;
}
/// write to stream
friend
std
::
ostream
&
operator
>>
(
const
json
&
j
,
std
::
ostream
&
o
)
{
o
<<
j
.
to
S
tring
();
o
<<
j
.
to
_s
tring
();
return
o
;
}
...
...
@@ -205,7 +205,7 @@ class json
}
/// 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
json
&
operator
+=
(
const
json
&
);
...
...
test/json_unit.cc
浏览文件 @
3bef1a50
...
...
@@ -15,7 +15,7 @@ TEST_CASE("array")
const
json
j_const
(
j
);
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"[]"
);
CHECK
(
j
.
to
_s
tring
()
==
"[]"
);
// iterators
CHECK
(
j
.
begin
()
!=
j
.
end
());
...
...
@@ -303,7 +303,7 @@ TEST_CASE("object")
const
json
j_const
=
j
;
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"{}"
);
CHECK
(
j
.
to
_s
tring
()
==
"{}"
);
// iterators
CHECK
(
j
.
begin
()
!=
j
.
end
());
...
...
@@ -683,7 +683,7 @@ TEST_CASE("null")
CHECK
(
j
.
type
()
==
json
::
value_type
::
null
);
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"null"
);
CHECK
(
j
.
to
_s
tring
()
==
"null"
);
// iterators
CHECK
(
j
.
begin
()
!=
j
.
end
());
...
...
@@ -753,7 +753,7 @@ TEST_CASE("string")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"
\"\"
"
);
CHECK
(
j
.
to
_s
tring
()
==
"
\"\"
"
);
// container members
CHECK
(
j
.
size
()
==
1
);
...
...
@@ -835,7 +835,7 @@ TEST_CASE("boolean")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"false"
);
CHECK
(
j
.
to
_s
tring
()
==
"false"
);
// container members
CHECK
(
j
.
size
()
==
1
);
...
...
@@ -914,7 +914,7 @@ TEST_CASE("number (int)")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"0"
);
CHECK
(
j
.
to
_s
tring
()
==
"0"
);
// container members
CHECK
(
j
.
size
()
==
1
);
...
...
@@ -1000,7 +1000,7 @@ TEST_CASE("number (float)")
CHECK
(
j
.
cbegin
()
!=
j
.
cend
());
// string representation of default value
CHECK
(
j
.
to
S
tring
()
==
"0.000000"
);
CHECK
(
j
.
to
_s
tring
()
==
"0.000000"
);
// container members
CHECK
(
j
.
size
()
==
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录