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

Side by Side Diff: lib/json/json.dart

Issue 10391139: Add a check to JSON code (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 | runtime/vm/debugger_api_impl.cc » ('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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("json"); 5 #library("json");
6 6
7 // Pure Dart implementation of JSON protocol. 7 // Pure Dart implementation of JSON protocol.
8 8
9 /** 9 /**
10 * Utility class to parse JSON and serialize objects to JSON. 10 * Utility class to parse JSON and serialize objects to JSON.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 static final String TRUE_STRING = "true"; 100 static final String TRUE_STRING = "true";
101 static final String FALSE_STRING = "false"; 101 static final String FALSE_STRING = "false";
102 102
103 103
104 static parse(String json) { 104 static parse(String json) {
105 return new _JsonParser._internal(json)._parseToplevel(); 105 return new _JsonParser._internal(json)._parseToplevel();
106 } 106 }
107 107
108 static objectLength(String str) { 108 static objectLength(String str) {
109 var p = new _JsonParser._internal(str); 109 var p = new _JsonParser._internal(str);
110 var firstToken = p._token();
111 if (firstToken != LBRACE) {
112 return 0;
113 }
110 try { 114 try {
111 p._parseObject(); 115 p._parseObject();
112 assert(p.position <= p.length); 116 assert(p.position <= p.length);
113 return p.position; 117 return p.position;
114 } catch (var e) { 118 } catch (var e) {
115 return 0; 119 return 0;
116 } 120 }
117 } 121 }
118 122
119 _JsonParser._internal(String json) 123 _JsonParser._internal(String json)
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 }); 544 });
541 _sb.add('}'); 545 _sb.add('}');
542 _seen.removeLast(); 546 _seen.removeLast();
543 return; 547 return;
544 548
545 default: 549 default:
546 throw const JsonUnsupportedObjectType(); 550 throw const JsonUnsupportedObjectType();
547 } 551 }
548 } 552 }
549 } 553 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698