Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonDoc data gets corrupted when passing to behaviour #801

Closed
doublec opened this issue May 5, 2016 · 1 comment
Closed

JsonDoc data gets corrupted when passing to behaviour #801

doublec opened this issue May 5, 2016 · 1 comment
Labels
triggers release Major issue that when fixed, results in an "emergency" release

Comments

@doublec
Copy link
Contributor

doublec commented May 5, 2016

I parse a string of JSON using the Json package. Printing the JsonDoc shows correct data. Passing that same JsonDoc to a behaviour then printing it shows corrupt data. Changing the behaviour to a function makes the data print correctly again.

The following is test code that demonstrates the issue:

use "json"

actor Main
   let test: String = "{\"result\":{\"version\":110200,\"protocolversion\":70002,\"walletversion\":60000,\"balance\":0.00000000,\"blocks\":410357,\"timeoffset\":-1,\"connections\":8,\"proxy\":\"\",\"difficulty\":178659257772.52728271,\"testnet\":false,\"keypoololdest\":1439278680,\"keypoolsize\":101,\"paytxfee\":0.00000000,\"relayfee\":0.00005000,\"errors\":\"\"},\"error\":null,\"id\":\"0\"}"

  new create(env:Env) =>
    try
      let json = recover iso JsonDoc end
      json.parse(test)
      env.out.print(json.string())
      foo(env, consume json)
    end

  be foo(env:Env, json: JsonDoc iso) =>
    env.out.print("foo: " + json.string())  

The first print of the json string in the constructor displays:

{
  "error": null,
  "id": "0",
  "result": {
    "relayfee": 5e-05.0,
    "balance": 0.0,
    "walletversion": 60000,
    "proxy": "",
    "connections": 8,
    "timeoffset": -1,
    "keypoololdest": 1439278680,
    "testnet": false,
    "paytxfee": 0.0,
    "difficulty": 1.78659e+11,
    "keypoolsize": 101,
    "protocolversion": 70002,
    "blocks": 410357,
    "version": 110200,
    "errors": ""
  }
}

The second print in the foo behaviour displays:

foo: {
  "error": null,
  "id": "0",
  "result": {
    "balance": "\n  \"",
    "walletversion": "\n  ",
    "proxy": "",
    "connections": "\n  \"error\": null",
    "timeoffset": "\n  \"error\": ",
    "protocolversion": "\n",
    "blocks": "\n  \"error",
    "errors": ""
  }
}

If the foo behaviour is changed to a function then it displays correctly.

@sylvanc sylvanc added difficulty: 1 - easy triggers release Major issue that when fixed, results in an "emergency" release and removed bug: 1 - needs investigation labels May 5, 2016
@sylvanc
Copy link
Contributor

sylvanc commented May 5, 2016

Great bug report. PR #805 fixes this.

@sylvanc sylvanc closed this as completed May 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triggers release Major issue that when fixed, results in an "emergency" release
Projects
None yet
Development

No branches or pull requests

3 participants