JRuby handling of strings makes json parser fail
------------------------------------------------

                 Key: JRUBY-3641
                 URL: http://jira.codehaus.org/browse/JRUBY-3641
             Project: JRuby
          Issue Type: Bug
    Affects Versions: JRuby 1.3RC1
         Environment:  I'm using JRuby 1.30RC-1 (note that I also had the same 
problem with JRuby 1.2.x) and json-jruby (1.1.3) running on top of Java vm 1.6 
update 13.
            Reporter: Julio Castillo
            Assignee: Thomas E Enebo


I ran into the following problem. I believe it is centered around the usee of 
slices within the json library or perhaps JRuby.
This runs fine on a real Ruby environment.

The following sample code has the scenario
.....
testStr0 = "{\"response\":{\"user\":{\"id\":100223}}}"
pp "1st RUN:" + testStr0
resp = JSON.parse(testStr0)
pp "1st RUN GOOD"

testStr1 = "/*{\"response\":{\"user\":{\"id\":100223}}}*/"
pp "2nd RUN:" + testStr1
testStr1 = testStr1[2,testStr1.length - 4]
# testStr1[2] = "X"
pp "2nd RUN trimmed:" + testStr1
resp = JSON.parse(testStr1)
pp "2nd RUN GOOD"
......

The last statement fails to print because of an exception:
C:/bin/jruby/lib/ruby/gems/1.8/gems/json-jruby-1.1.3-universal-java-1.6/lib/json/common.rb:122:in
 `parse': invalid value for Integer: "0223}}" (ArgumentError)

If I uncomment the commented out line, then the parsing succeeds indicating 
that the path in the code changed because the string had to be recreated before 
parsing?
Someone is using slices and that I believe creates the problem

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to