mirror of
https://github.com/nlohmann/json.git
synced 2026-10-08 15:37:13 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8dfc0d0f9 |
No files matched your search
@@ -19,25 +19,9 @@ int main()
|
|||||||
<< j.contains("/array/1"_json_pointer) << '\n'
|
<< j.contains("/array/1"_json_pointer) << '\n'
|
||||||
<< j.contains("/array/-"_json_pointer) << '\n'
|
<< j.contains("/array/-"_json_pointer) << '\n'
|
||||||
<< j.contains("/array/4"_json_pointer) << '\n'
|
<< j.contains("/array/4"_json_pointer) << '\n'
|
||||||
<< j.contains("/baz"_json_pointer) << std::endl;
|
<< j.contains("/baz"_json_pointer) << '\n'
|
||||||
|
// an array index with a leading '0' is not found
|
||||||
try
|
<< j.contains("/array/01"_json_pointer) << '\n'
|
||||||
{
|
// an array index that is not a number is not found
|
||||||
// try to use an array index with leading '0'
|
<< j.contains("/array/one"_json_pointer) << std::endl;
|
||||||
j.contains("/array/01"_json_pointer);
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
std::cout << e.what() << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// try to use an array index that is not a number
|
|
||||||
j.contains("/array/one"_json_pointer);
|
|
||||||
}
|
|
||||||
catch (const json::parse_error& e)
|
|
||||||
{
|
|
||||||
std::cout << e.what() << '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,3 +5,5 @@ true
|
|||||||
false
|
false
|
||||||
false
|
false
|
||||||
false
|
false
|
||||||
|
false
|
||||||
|
false
|
||||||
@@ -8,7 +8,7 @@ int main()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// parsing input with a syntax error
|
// parsing input with a syntax error
|
||||||
json::parse("[1,2,3,]");
|
json j = json::parse("[1,2,3,]");
|
||||||
}
|
}
|
||||||
catch (const json::parse_error& e)
|
catch (const json::parse_error& e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user