Skip to content

Serialisation (toJson)

dxstiny edited this page Jul 1, 2022 · 2 revisions

The method "toJson()" (synchronous for all objects except cevlib.match.Match) returns a serialisable of type dict with all public properties of the object

Serialising the whole match object

import asyncio

from cevlib.match import Match

import json

async def main():
    match = await Match.byUrl("https://www.cev.eu/match-centres/2022-european-cups/cev-volleyball-challenge-cup-2022-women/chcw-78-rc-cannes-v-savino-del-bene-scandicci/")

    x = await match.toJson()
    with open("sample.json", "w") as outfile:
        jdata = json.dumps(x, indent=4)
        outfile.write(jdata)

asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())

Clone this wiki locally