Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
161c74a9
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,发现更多精彩内容 >>
提交
161c74a9
编写于
7月 28, 2016
作者:
N
Niels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some cleanup
上级
6297631e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
42 addition
and
5 deletion
+42
-5
src/json.hpp
src/json.hpp
+17
-2
src/json.hpp.re2c
src/json.hpp.re2c
+25
-3
未找到文件。
src/json.hpp
浏览文件 @
161c74a9
...
...
@@ -760,6 +760,7 @@ class basic_json
};
std
::
unique_ptr
<
T
,
decltype
(
deleter
)
>
object
(
alloc
.
allocate
(
1
),
deleter
);
alloc
.
construct
(
object
.
get
(),
std
::
forward
<
Args
>
(
args
)...);
assert
(
object
.
get
()
!=
nullptr
);
return
object
.
release
();
}
...
...
@@ -4597,6 +4598,10 @@ class basic_json
object | result of function `object_t::empty()`
array | result of function `array_t::empty()`
@note This function does not return whether a string stored as JSON value
is empty - it returns whether the JSON container itself is empty which is
false in the case of a string.
@complexity Constant, as long as @ref array_t and @ref object_t satisfy
the Container concept; that is, their `empty()` functions have constant
complexity.
...
...
@@ -4626,12 +4631,14 @@ class basic_json
case
value_t
::
array
:
{
// delegate call to array_t::empty()
assert
(
m_value
.
array
!=
nullptr
);
return
m_value
.
array
->
empty
();
}
case
value_t
::
object
:
{
// delegate call to object_t::empty()
assert
(
m_value
.
object
!=
nullptr
);
return
m_value
.
object
->
empty
();
}
...
...
@@ -4660,6 +4667,10 @@ class basic_json
object | result of function object_t::size()
array | result of function array_t::size()
@note This function does not return the length of a string stored as JSON
value - it returns the number of elements in the JSON value which is 1 in
the case of a string.
@complexity Constant, as long as @ref array_t and @ref object_t satisfy
the Container concept; that is, their size() functions have constant
complexity.
...
...
@@ -4690,12 +4701,14 @@ class basic_json
case
value_t
::
array
:
{
// delegate call to array_t::size()
assert
(
m_value
.
array
!=
nullptr
);
return
m_value
.
array
->
size
();
}
case
value_t
::
object
:
{
// delegate call to object_t::size()
assert
(
m_value
.
object
!=
nullptr
);
return
m_value
.
object
->
size
();
}
...
...
@@ -4750,12 +4763,14 @@ class basic_json
{
case
value_t
::
array
:
{
// delegate call to array_t::max_size()
assert
(
m_value
.
array
!=
nullptr
);
return
m_value
.
array
->
max_size
();
}
case
value_t
::
object
:
{
// delegate call to object_t::max_size()
assert
(
m_value
.
object
!=
nullptr
);
return
m_value
.
object
->
max_size
();
}
...
...
@@ -5844,14 +5859,14 @@ class basic_json
// string->float->string, string->double->string or string->long
// double->string; to be safe, we read this value from
// std::numeric_limits<number_float_t>::digits10
const
auto
old_pre
icis
on
=
o
.
precision
(
std
::
numeric_limits
<
double
>::
digits10
);
const
auto
old_pre
cisi
on
=
o
.
precision
(
std
::
numeric_limits
<
double
>::
digits10
);
// do the actual serialization
j
.
dump
(
o
,
pretty_print
,
static_cast
<
unsigned
int
>
(
indentation
));
// reset locale and precision
o
.
imbue
(
old_locale
);
o
.
precision
(
old_pre
icis
on
);
o
.
precision
(
old_pre
cisi
on
);
return
o
;
}
...
...
src/json.hpp.re2c
浏览文件 @
161c74a9
...
...
@@ -760,6 +760,7 @@ class basic_json
};
std::unique_ptr<T, decltype(deleter)> object(alloc.allocate(1), deleter);
alloc.construct(object.get(), std::forward<Args>(args)...);
assert(object.get() != nullptr);
return object.release();
}
...
...
@@ -4597,6 +4598,10 @@ class basic_json
object | result of function `object_t::empty()`
array | result of function `array_t::empty()`
@note This function does not return whether a string stored as JSON value
is empty - it returns whether the JSON container itself is empty which is
false in the case of a string.
@complexity Constant, as long as @ref array_t and @ref object_t satisfy
the Container concept; that is, their `empty()` functions have constant
complexity.
...
...
@@ -4626,12 +4631,14 @@ class basic_json
case value_t::array:
{
// delegate call to array_t::empty()
assert(m_value.array != nullptr);
return m_value.array->empty();
}
case value_t::object:
{
// delegate call to object_t::empty()
assert(m_value.object != nullptr);
return m_value.object->empty();
}
...
...
@@ -4660,6 +4667,10 @@ class basic_json
object | result of function object_t::size()
array | result of function array_t::size()
@note This function does not return the length of a string stored as JSON
value - it returns the number of elements in the JSON value which is 1 in
the case of a string.
@complexity Constant, as long as @ref array_t and @ref object_t satisfy
the Container concept; that is, their size() functions have constant
complexity.
...
...
@@ -4690,12 +4701,14 @@ class basic_json
case value_t::array:
{
// delegate call to array_t::size()
assert(m_value.array != nullptr);
return m_value.array->size();
}
case value_t::object:
{
// delegate call to object_t::size()
assert(m_value.object != nullptr);
return m_value.object->size();
}
...
...
@@ -4750,12 +4763,14 @@ class basic_json
{
case value_t::array:
{
// delegate call to array_t::max_size()
assert(m_value.array != nullptr);
return m_value.array->max_size();
}
case value_t::object:
{
// delegate call to object_t::max_size()
assert(m_value.object != nullptr);
return m_value.object->max_size();
}
...
...
@@ -5844,14 +5859,14 @@ class basic_json
// string->float->string, string->double->string or string->long
// double->string; to be safe, we read this value from
// std::numeric_limits<number_float_t>::digits10
const auto old_pre
icis
on = o.precision(std::numeric_limits<double>::digits10);
const auto old_pre
cisi
on = o.precision(std::numeric_limits<double>::digits10);
// do the actual serialization
j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
// reset locale and precision
o.imbue(old_locale);
o.precision(old_pre
icis
on);
o.precision(old_pre
cisi
on);
return o;
}
...
...
@@ -9560,7 +9575,7 @@ struct hash<nlohmann::json>
@brief user-defined string literal for JSON values
This operator implements a user-defined string literal for JSON objects. It
can be used by adding
\p "_json"
to a string literal and returns a JSON object
can be used by adding
`"_json"`
to a string literal and returns a JSON object
if no parse error occurred.
@param[in] s a string representation of a JSON object
...
...
@@ -9576,6 +9591,13 @@ inline nlohmann::json operator "" _json(const char* s, std::size_t)
/*!
@brief user-defined string literal for JSON pointer
This operator implements a user-defined string literal for JSON Pointers. It
can be used by adding `"_json"` to a string literal and returns a JSON pointer
object if no parse error occurred.
@param[in] s a string representation of a JSON Pointer
@return a JSON pointer object
@since version 2.0.0
*/
inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录