Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(856)

Side by Side Diff: base/json/json_string_value_serializer.cc

Issue 130563010: Invalid JSON output when BinaryValue suppressed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: NOTREACHED() & return false at end of function. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/json/json_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/json_string_value_serializer.h" 5 #include "base/json/json_string_value_serializer.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
(...skipping 14 matching lines...) Expand all
25 bool omit_binary_values) { 25 bool omit_binary_values) {
26 if (!json_string_ || initialized_with_const_string_) 26 if (!json_string_ || initialized_with_const_string_)
27 return false; 27 return false;
28 28
29 int options = 0; 29 int options = 0;
30 if (omit_binary_values) 30 if (omit_binary_values)
31 options |= base::JSONWriter::OPTIONS_OMIT_BINARY_VALUES; 31 options |= base::JSONWriter::OPTIONS_OMIT_BINARY_VALUES;
32 if (pretty_print_) 32 if (pretty_print_)
33 options |= base::JSONWriter::OPTIONS_PRETTY_PRINT; 33 options |= base::JSONWriter::OPTIONS_PRETTY_PRINT;
34 34
35 base::JSONWriter::WriteWithOptions(&root, options, json_string_); 35 return base::JSONWriter::WriteWithOptions(&root, options, json_string_);
36 return true;
37 } 36 }
38 37
39 Value* JSONStringValueSerializer::Deserialize(int* error_code, 38 Value* JSONStringValueSerializer::Deserialize(int* error_code,
40 std::string* error_str) { 39 std::string* error_str) {
41 if (!json_string_) 40 if (!json_string_)
42 return NULL; 41 return NULL;
43 42
44 return base::JSONReader::ReadAndReturnError(*json_string_, 43 return base::JSONReader::ReadAndReturnError(*json_string_,
45 allow_trailing_comma_ ? base::JSON_ALLOW_TRAILING_COMMAS : 44 allow_trailing_comma_ ? base::JSON_ALLOW_TRAILING_COMMAS :
46 base::JSON_PARSE_RFC, 45 base::JSON_PARSE_RFC,
47 error_code, error_str); 46 error_code, error_str);
48 } 47 }
OLDNEW
« no previous file with comments | « no previous file | base/json/json_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698