| 105 | |
| 106 | |
| 107 | void ParserImpl::stripComments(std::string& json) |
| 108 | { |
| 109 | if (_allowComments) |
| 110 | { |
| 111 | bool inString = false; |
| 112 | bool inComment = false; |
| 113 | char prevChar = 0; |
| 114 | std::string::iterator it = json.begin(); |
| 115 | for (; it != json.end();) |
| 116 | { |
| 117 | if (*it == '"' && !inString) inString = true; |
| 118 | else inString = false; |
| 119 | if (!inString) |
| 120 | { |
| 121 | if (*it == '/' && it + 1 != json.end() && *(it + 1) == '*') |
| 122 | inComment = true; |
| 123 | } |
| 124 | if (inComment) |
| 125 | { |
| 126 | char c = *it; |
| 127 | it = json.erase(it); |
| 128 | if (prevChar == '*' && c == '/') |
| 129 | { |
| 130 | inComment = false; |
| 131 | prevChar = 0; |
| 132 | } |
| 133 | else prevChar = c; |
| 134 | } |
| 135 | else ++it; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | |
| 141 | void ParserImpl::handleArray() |