Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
Fixed Integer#to_json going in an infinite recursion.
Browse files Browse the repository at this point in the history
Closes #3.
  • Loading branch information
mernen committed Jun 22, 2010
1 parent 6f1dade commit b9612e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/json/ext/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ private Generator() {
return session.infect(handler.generateNew(session, object, depth));
}

/**
* Encodes the given object as a JSON string, detecting the appropriate handler
* for the given object.
*/
static <T extends IRubyObject> RubyString
generateJson(ThreadContext context, T object, IRubyObject[] args) {
Handler<? super T> handler = getHandlerFor(context.getRuntime(), object);
return generateJson(context, object, handler, args);
}

/**
* Encodes the given object as a JSON string, using the appropriate
* handler if one is found or calling #to_json if not.
Expand Down
3 changes: 1 addition & 2 deletions src/json/ext/GeneratorMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public static class RbInteger {
@JRubyMethod(rest=true)
public static IRubyObject to_json(ThreadContext context,
IRubyObject vSelf, IRubyObject[] args) {
return Generator.generateJson(context, vSelf,
Generator.GENERIC_HANDLER, args);
return Generator.generateJson(context, vSelf, args);
}
};

Expand Down

0 comments on commit b9612e7

Please sign in to comment.