OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/json_reader.h" | 5 #include "base/json_reader.h" |
6 | 6 |
7 #include "base/float_util.h" | 7 #include "base/float_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 json_pos_ += token.length; | 270 json_pos_ += token.length; |
271 token = ParseToken(); | 271 token = ParseToken(); |
272 if (token.type != Token::OBJECT_PAIR_SEPARATOR) | 272 if (token.type != Token::OBJECT_PAIR_SEPARATOR) |
273 return NULL; | 273 return NULL; |
274 | 274 |
275 json_pos_ += token.length; | 275 json_pos_ += token.length; |
276 token = ParseToken(); | 276 token = ParseToken(); |
277 Value* dict_value = BuildValue(false); | 277 Value* dict_value = BuildValue(false); |
278 if (!dict_value) | 278 if (!dict_value) |
279 return NULL; | 279 return NULL; |
280 static_cast<DictionaryValue*>(node.get())->Set(dict_key, dict_value); | 280 static_cast<DictionaryValue*>(node.get())->Set( |
| 281 WideToUTF16Hack(dict_key), dict_value); |
281 | 282 |
282 // After a key/value pair, we expect a comma or the end of the | 283 // After a key/value pair, we expect a comma or the end of the |
283 // object. | 284 // object. |
284 token = ParseToken(); | 285 token = ParseToken(); |
285 if (token.type == Token::LIST_SEPARATOR) { | 286 if (token.type == Token::LIST_SEPARATOR) { |
286 json_pos_ += token.length; | 287 json_pos_ += token.length; |
287 token = ParseToken(); | 288 token = ParseToken(); |
288 // Trailing commas are invalid according to the JSON RFC, but some | 289 // Trailing commas are invalid according to the JSON RFC, but some |
289 // consumers need the parsing leniency, so handle accordingly. | 290 // consumers need the parsing leniency, so handle accordingly. |
290 if (token.type == Token::OBJECT_END) { | 291 if (token.type == Token::OBJECT_END) { |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 if (*pos == '\n') { | 632 if (*pos == '\n') { |
632 ++line_number; | 633 ++line_number; |
633 column_number = 1; | 634 column_number = 1; |
634 } else { | 635 } else { |
635 ++column_number; | 636 ++column_number; |
636 } | 637 } |
637 } | 638 } |
638 | 639 |
639 error_message_ = FormatErrorMessage(line_number, column_number, description); | 640 error_message_ = FormatErrorMessage(line_number, column_number, description); |
640 } | 641 } |
OLD | NEW |