| 52 | |
| 53 | |
| 54 | void ParserImpl::handle(const std::string& json) |
| 55 | { |
| 56 | _currentDepth = 0; |
| 57 | if (!_allowNullByte && json.find("\\u0000") != json.npos) |
| 58 | throw JSONException("Null bytes in strings not allowed."); |
| 59 | |
| 60 | try |
| 61 | { |
| 62 | json_open_buffer(_pJSON, json.data(), json.size()); |
| 63 | checkError(); |
| 64 | ////////////////////////////////// |
| 65 | // Underlying parser is capable of parsing multiple consecutive JSONs; |
| 66 | // we do not currently support this feature; to force error on |
| 67 | // excessive characters past valid JSON end, this MUST be called |
| 68 | // AFTER opening the buffer - otherwise it is overwritten by |
| 69 | // json_open*() call, which calls internal init() |
| 70 | json_set_streaming(_pJSON, false); |
| 71 | ///////////////////////////////// |
| 72 | handle(); checkError(); |
| 73 | if (JSON_DONE != json_next(_pJSON)) |
| 74 | throw JSONException("Excess characters found after JSON end."); |
| 75 | json_close(_pJSON); |
| 76 | } |
| 77 | catch (std::exception&) |
| 78 | { |
| 79 | json_close(_pJSON); |
| 80 | throw; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | |
| 85 | Dynamic::Var ParserImpl::parseImpl(const std::string& json) |
nothing calls this directly
no test coverage detected