Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
9da8770f
Commit
9da8770f
authored
Dec 07, 2015
by
Niels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ignore UTF-8 byte order mark (fixes #152)
parent
e0d334c4
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
240 additions
and
181 deletions
+240
-181
src/json.hpp
src/json.hpp
+210
-172
src/json.hpp.re2c
src/json.hpp.re2c
+19
-9
test/json_nlohmann_tests/bom.json
test/json_nlohmann_tests/bom.json
+3
-0
test/unit.cpp
test/unit.cpp
+8
-0
No files found.
src/json.hpp
View file @
9da8770f
This diff is collapsed.
Click to expand it.
src/json.hpp.re2c
View file @
9da8770f
...
...
@@ -4437,6 +4437,8 @@ class basic_json
LL(1) parser. The complexity can be higher if the parser callback function
@a cb has a super-linear complexity.
@note A UTF-8 byte order mark is silently ignored.
@liveexample{The example below demonstrates the parse function with and
without callback function.,parse__string__parser_callback_t}
...
...
@@ -4462,6 +4464,8 @@ class basic_json
LL(1) parser. The complexity can be higher if the parser callback function
@a cb has a super-linear complexity.
@note A UTF-8 byte order mark is silently ignored.
@liveexample{The example below demonstrates the parse function with and
without callback function.,parse__istream__parser_callback_t}
...
...
@@ -4491,6 +4495,8 @@ class basic_json
@complexity Linear in the length of the input. The parser is a predictive
LL(1) parser.
@note A UTF-8 byte order mark is silently ignored.
@liveexample{The example below shows how a JSON value is constructed by
reading a serialization from a stream.,operator_deserialize}
...
...
@@ -6000,20 +6006,24 @@ class basic_json
m_start = m_cursor;
/*!re2c
re2c:define:YYCTYPE = lexer_char_t;
re2c:define:YYCURSOR = m_cursor;
re2c:define:YYLIMIT = m_limit;
re2c:define:YYMARKER = m_marker;
re2c:define:YYFILL = "yyfill(); // LCOV_EXCL_LINE";
re2c:define:YYCTYPE
= lexer_char_t;
re2c:define:YYCURSOR
= m_cursor;
re2c:define:YYLIMIT
= m_limit;
re2c:define:YYMARKER
= m_marker;
re2c:define:YYFILL
= "yyfill(); // LCOV_EXCL_LINE";
re2c:yyfill:parameter = 0;
re2c:indent:string = " ";
re2c:indent:top = 1;
re2c:labelprefix = "basic_json_parser_";
re2c:indent:string
= " ";
re2c:indent:top
= 1;
re2c:labelprefix
= "basic_json_parser_";
// whitespace
//
ignore
whitespace
ws = [ \t\n\r]+;
ws { return scan(); }
// ignore byte-order-mark
bom = "\xEF\xBB\xBF";
bom { return scan(); }
// structural characters
"[" { return token_type::begin_array; }
"]" { return token_type::end_array; }
...
...
test/json_nlohmann_tests/bom.json
0 → 100644
View file @
9da8770f
{
"foo"
:
true
}
test/unit.cpp
View file @
9da8770f
...
...
@@ -10022,6 +10022,14 @@ TEST_CASE("Unicode", "[hide]")
// the array has 1112064 + 1 elemnts (a terminating "null" value)
CHECK
(
j
.
size
()
==
1112065
);
}
SECTION
(
"ignore byte-order-mark"
)
{
// read a file with a UTF-8 BOM
std
::
ifstream
f
(
"test/json_nlohmann_tests/bom.json"
);
json
j
;
CHECK_NOTHROW
(
j
<<
f
);
}
}
TEST_CASE
(
"regression tests"
)
...
...
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