You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.
Use case: Fetch a large group of matches and want to store them somewhere for later analysis offline. Want to be able to convert a match (with all included player, roster, participant, and asset objects) to JSON that can be written to a file, then deserialized back into the same hierarchy of Match/Player/Roster/Participant/Asset objects later. For bonus points, include telemetry data.
I include here some CoffeeScript code that seems to work, but native support is better than my hacking, of course.
vgObjectToJSON= ( object ) ->result=data:object.datafor own name, ctor ofvg.modelsif name isnt'Base'and object instanceof ctor
result.ctor= name
for relationship inobject.relationships? [ ]
type=relationship.typesubobj= object[type]
if subobj instanceofArray
result[type] = ( vgObjectToJSON s for s in subobj )
else
result[type] =vgObjectToJSON subobj
# in case I've fetched and embedded telemetry earlier:result.telemetry=object.telemetry
result
vgObjectFromJSON= ( json ) ->iftypeof json is'string'thenjson=JSON.parse json
ctor=vg.models[json.ctor]
deletejson.ctortelemetry=json.telemetrydeletejson.telemetryresult=newctorjson.datafor relationship inresult.relationships? [ ]
type=relationship.typesubobj= json[type]
if subobj instanceofArray
result[type] = ( vgObjectFromJSON s for s in subobj )
else
result[type] =vgObjectFromJSON subobj
result.telemetry= telemetry
result
The text was updated successfully, but these errors were encountered:
Use case: Fetch a large group of matches and want to store them somewhere for later analysis offline. Want to be able to convert a match (with all included player, roster, participant, and asset objects) to JSON that can be written to a file, then deserialized back into the same hierarchy of
Match
/Player
/Roster
/Participant
/Asset
objects later. For bonus points, include telemetry data.I include here some CoffeeScript code that seems to work, but native support is better than my hacking, of course.
The text was updated successfully, but these errors were encountered: