Blizzard / heroprotocol

Python library to decode Heroes of the Storm replays
MIT License
398 stars 69 forks source link

Invalid json with --trackerevents #26

Closed jbailey closed 6 years ago

jbailey commented 8 years ago

python /Users/jbailey/workspace/heroprotocol/heroprotocol.py --json --trackerevents Sky\ Temple\ (82).StormReplay

I get the following error when running the json through a parser. Note, this is outside of python, but json is json.

Parse Error: "m_slotId": 0}{ "m_playerId":

dnlgrv commented 8 years ago

Yeah there are a lot of instances of these unfortunately. The JSON implementation in the codebase doesn't create a single JSON blob, but rather converts the python structs to be in the JSON format. I realise that doesn't help you but hopefully explains what's going on :)

cherscarlett commented 8 years ago

As Daniel said, it's because it's not straight converting the entire Python dict to valid JSON. I would recommend looking at other branches to see how they've gotten around this. My branch splits into a py package, but you can see in the function I added how I handled the output JSON.

On Fri, Feb 12, 2016 at 12:25 PM, Daniel Grieve notifications@github.com wrote:

Yeah there are a lot of instances of these unfortunately. The JSON implementation in the codebase doesn't create a single JSON blob, but rather converts the python structs to be in the JSON format. I realise that doesn't help you but hopefully explains what's going on :)

— Reply to this email directly or view it on GitHub https://github.com/Blizzard/heroprotocol/issues/26#issuecomment-183475978 .

Cher Stewart

You cannot do all the good the world needs, but the world needs all the good you can do.

mikeeheler commented 6 years ago

For posterity, the JSON output is a line-delimited stream. Read the JSON output line-by-line and decode each line independently as a sequence of events.