[DEV] add compatibility with the simple quote ' naming instead of "
This commit is contained in:
parent
226d95135c
commit
bcab8b0706
@ -67,7 +67,8 @@ bool ejson::Array::iParse(const std::string& _data, size_t& _pos, ejson::filePos
|
||||
}
|
||||
tmpElement->iParse(_data, iii, _filePos, _doc);
|
||||
m_value.push_back(tmpElement);
|
||||
} else if (_data[iii] == '"') {
|
||||
} else if ( _data[iii] == '"'
|
||||
|| _data[iii] == '\'') {
|
||||
// find a string:
|
||||
JSON_PARSE_ELEMENT("find String quoted");
|
||||
ejson::String * tmpElement = new ejson::String();
|
||||
|
0
ejson/Array.h
Executable file → Normal file
0
ejson/Array.h
Executable file → Normal file
0
ejson/Boolean.h
Executable file → Normal file
0
ejson/Boolean.h
Executable file → Normal file
0
ejson/Null.h
Executable file → Normal file
0
ejson/Null.h
Executable file → Normal file
0
ejson/Number.h
Executable file → Normal file
0
ejson/Number.h
Executable file → Normal file
@ -73,14 +73,16 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
|
||||
} else {
|
||||
if (mode == parseName) {
|
||||
JSON_PARSE_ELEMENT("name START " << '"');
|
||||
if (_data[iii] == '"') {
|
||||
if ( _data[iii] == '"'
|
||||
|| _data[iii] == '\'') {
|
||||
char startValue=_data[iii];
|
||||
currentName = "";
|
||||
for (iii++; iii<_data.size(); iii++) {
|
||||
_filePos.check(_data[iii]);
|
||||
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
|
||||
drawElementParsed(_data[iii], _filePos);
|
||||
drawElementParsed(_data[iii], _filePos);
|
||||
#endif
|
||||
if (_data[iii] == '\"') {
|
||||
if (_data[iii] == startValue) {
|
||||
mode = parseMiddle;
|
||||
break;
|
||||
} else {
|
||||
@ -92,7 +94,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
|
||||
for (iii++; iii<_data.size(); iii++) {
|
||||
_filePos.check(_data[iii]);
|
||||
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
|
||||
drawElementParsed(_data[iii], _filePos);
|
||||
drawElementParsed(_data[iii], _filePos);
|
||||
#endif
|
||||
if (false == checkString(_data[iii])) {
|
||||
mode = parseMiddle;
|
||||
@ -129,7 +131,8 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
|
||||
tmpElement->iParse(_data, iii, _filePos, _doc);
|
||||
add(currentName, tmpElement);
|
||||
currentName = "";
|
||||
} else if (_data[iii] == '"') {
|
||||
} else if ( _data[iii] == '"'
|
||||
|| _data[iii] == '\'') {
|
||||
// find a string:
|
||||
JSON_PARSE_ELEMENT("find String quoted");
|
||||
ejson::String * tmpElement = new ejson::String();
|
||||
|
0
ejson/Object.h
Executable file → Normal file
0
ejson/Object.h
Executable file → Normal file
@ -20,6 +20,7 @@
|
||||
|
||||
bool ejson::String::iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
|
||||
JSON_PARSE_ELEMENT("start parse : 'String' ");
|
||||
char end = _data[_pos];
|
||||
for (size_t iii=_pos+1; iii<_data.size(); iii++) {
|
||||
_filePos.check(_data[iii]);
|
||||
#ifdef ENABLE_DISPLAY_PARSED_ELEMENT
|
||||
@ -27,7 +28,7 @@ bool ejson::String::iParse(const std::string& _data, size_t& _pos, ejson::filePo
|
||||
#endif
|
||||
ejson::filePos tmpPos;
|
||||
// TODO : manage \x
|
||||
if( _data[iii]!= '\"') {
|
||||
if(_data[iii] != end) {
|
||||
m_value += _data[iii];
|
||||
} else {
|
||||
_pos = iii;
|
||||
|
0
ejson/String.h
Executable file → Normal file
0
ejson/String.h
Executable file → Normal file
0
ejson/Value.h
Executable file → Normal file
0
ejson/Value.h
Executable file → Normal file
0
ejson/ejson.h
Executable file → Normal file
0
ejson/ejson.h
Executable file → Normal file
Loading…
x
Reference in New Issue
Block a user