zincware / znjson Goto Github PK
View Code? Open in Web Editor NEWPackage to Encode/Decode some common file formats to json
License: Apache License 2.0
Package to Encode/Decode some common file formats to json
License: Apache License 2.0
Lines 7 to 16 in 553e366
Currently you have to do:
znjson.config.register(CustomConverter)
json.dump(data, cls=znjson.ZnEncoder)
but maybe you only want to use a specific converter which could look something like:
json.dump(data, cls=znjson.ZnEncoder.from_converter(CustomConverter, allow_default=True)) # this could be a list of converters
# or
json.dump(data, cls=CustomConverter) # this would allow only one converter
provide patched zndraw.json
module and a magic patch
Currently large numpy arrays will be stored uncompressed and can take a lot of space.
Currently if _type
is there it will try to deserialize and fail. Sometimes it could be useful to only serialize a specific type.
see https://github.com/zincware/ZnTrack/blob/4551776c4397a1fc12b82829cbf3ee292faeea55/zntrack/fields/zn/__init__.py#L316-L320
where we only would like to serialize the converters.
To avoid issues when e.g. de-serializing a dict {"Path": "this is some string"}
which should return a dict and not a Path object,
it would be possible to serialize all objects to the dict {<type>: val}
which would yield{"dict": {"Path": "this is some string"}}
and therefore can not be confused with {"Path": "this is some string"}
.
The package https://github.com/jsonpickle/jsonpickle provides similar functionality
A numpy (and maybe also pandas) converter could also convert to lists instead of binary.
This could be useful for small arrays.
It is currently possible to register two converters with the same representation: str
which can be avoided by checking for uniqueness in the register command..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.