summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2015-06-13 12:55:29 +0200
committerFlorian Frank <flori@ping.de>2015-06-13 12:55:29 +0200
commit4b843b585060212e8c396073f79627bf081491db (patch)
tree4eb45ffa67e8cad4f7f7dc2a0615a678344471fb /java
parent280005f5bc5e8e120f7ed717f7a86eaad2dae6b4 (diff)
downloadjson-4b843b585060212e8c396073f79627bf081491db.tar.gz
Remove generate restriction for […]/{…}
Diffstat (limited to 'java')
-rw-r--r--java/src/json/ext/GeneratorState.java32
1 files changed, 0 insertions, 32 deletions
diff --git a/java/src/json/ext/GeneratorState.java b/java/src/json/ext/GeneratorState.java
index 3065307..db4f3f5 100644
--- a/java/src/json/ext/GeneratorState.java
+++ b/java/src/json/ext/GeneratorState.java
@@ -208,10 +208,6 @@ public class GeneratorState extends RubyObject {
@JRubyMethod
public IRubyObject generate(ThreadContext context, IRubyObject obj) {
RubyString result = Generator.generateJson(context, obj, this);
- if (!quirksMode && !objectOrArrayLiteral(result)) {
- throw Utils.newException(context, Utils.M_GENERATOR_ERROR,
- "only generation of JSON objects or arrays allowed");
- }
RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
if (info.encodingsSupported()) {
result.force_encoding(context, info.utf8.get());
@@ -219,34 +215,6 @@ public class GeneratorState extends RubyObject {
return result;
}
- /**
- * Ensures the given string is in the form "[...]" or "{...}", being
- * possibly surrounded by white space.
- * The string's encoding must be ASCII-compatible.
- * @param value
- * @return
- */
- private static boolean objectOrArrayLiteral(RubyString value) {
- ByteList bl = value.getByteList();
- int len = bl.length();
-
- for (int pos = 0; pos < len - 1; pos++) {
- int b = bl.get(pos);
- if (Character.isWhitespace(b)) continue;
-
- // match the opening brace
- switch (b) {
- case '[':
- return matchClosingBrace(bl, pos, len, ']');
- case '{':
- return matchClosingBrace(bl, pos, len, '}');
- default:
- return false;
- }
- }
- return false;
- }
-
private static boolean matchClosingBrace(ByteList bl, int pos, int len,
int brace) {
for (int endPos = len - 1; endPos > pos; endPos--) {