mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 03:50:16 +00:00
* Add cjson module * Create structure for cjson module * Implemenet loads function * Convert cJsonBool to python boolean * Implement dumps function * Convert json bool and null to python Bool and None * necessary changes of project structure * Update amalgamate.py * Support non-dictionary json objects (list, tuple, string, number, bool, null) * Fix tests * fix CI * fix CI * Convert python to cJson and then to string * Delete cJSON object after use --------- Co-authored-by: Mahbub Alam <alam.mahbub214@gmail.com> Co-authored-by: blueloveTH <blueloveth@foxmail.com>
25 lines
633 B
Python
25 lines
633 B
Python
try:
|
|
import cjson as json
|
|
print('[INFO] cjson is used')
|
|
except ImportError:
|
|
import json
|
|
|
|
_2489KB = 'WorldMap_GridVania_layout.ldtk'
|
|
_1093KB = 'WorldMap_Free_layout.ldtk'
|
|
_339KB = 'Typical_2D_platformer_example.ldtk'
|
|
|
|
with open(f'res/{_339KB}', 'r') as f:
|
|
json_content = f.read()
|
|
|
|
data: dict = json.loads(json_content)
|
|
assert isinstance(data, dict)
|
|
|
|
dumped: str = json.dumps(data)
|
|
loaded: dict = json.loads(dumped)
|
|
assert data == loaded
|
|
|
|
# import pickle
|
|
##### very very slow!! DO NOT RUN IT
|
|
# data_pickled: bytes = pickle.dumps(data)
|
|
# assert isinstance(data_pickled, bytes)
|
|
# assert pickle.loads(data_pickled) == data |