ramonhagenaars / Jsons
Licence: mit
🐍 A Python lib for (de)serializing Python objects to/from JSON
Stars: ✭ 178
Programming Languages
Projects that are alternatives of or similar to Jsons
Fastjson
A fast JSON parser/generator for Java.
Stars: ✭ 23,997 (+13381.46%)
Mutual labels: json, serialization, json-parser
Thorsserializer
C++ Serialization library for JSON
Stars: ✭ 241 (+35.39%)
Mutual labels: json, serialization, json-parser
Go
A high-performance 100% compatible drop-in replacement of "encoding/json"
Stars: ✭ 10,248 (+5657.3%)
Mutual labels: json, serialization, json-parser
Flatcc
FlatBuffers Compiler and Library in C for C
Stars: ✭ 434 (+143.82%)
Mutual labels: json, serialization, json-parser
Daw json link
Static JSON parsing in C++
Stars: ✭ 146 (-17.98%)
Mutual labels: json, serialization, json-parser
Dictfier
Python library to convert/serialize class instances(Objects) both flat and nested into a dictionary data structure. It's very useful in converting Python Objects into JSON format
Stars: ✭ 67 (-62.36%)
Mutual labels: json, serialization, json-parser
Java
jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
Stars: ✭ 1,308 (+634.83%)
Mutual labels: json, serialization, json-parser
Json
Lighter and Faster Json Serialization tool.
Stars: ✭ 128 (-28.09%)
Mutual labels: json, serialization
Protostuff
Java serialization library, proto compiler, code generator
Stars: ✭ 1,730 (+871.91%)
Mutual labels: json, serialization
Pyjson tricks
Extra features for Python's JSON: comments, order, numpy, pandas, datetimes, and many more! Simple but customizable.
Stars: ✭ 131 (-26.4%)
Mutual labels: json, serialization
Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (-1.69%)
Mutual labels: json, json-parser
Qxorm
QxOrm library - C++ Qt ORM (Object Relational Mapping) and ODM (Object Document Mapper) library - Official repository
Stars: ✭ 176 (-1.12%)
Mutual labels: json, serialization
Borer
Efficient CBOR and JSON (de)serialization in Scala
Stars: ✭ 131 (-26.4%)
Mutual labels: json, serialization
Dataclass factory
Modern way to convert python dataclasses or other objects to and from more common types like dicts or json-like structures
Stars: ✭ 116 (-34.83%)
Mutual labels: json, serialization
Noproto
Flexible, Fast & Compact Serialization with RPC
Stars: ✭ 138 (-22.47%)
Mutual labels: json, serialization
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (-35.96%)
Mutual labels: json, serialization
Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (-25.84%)
Mutual labels: json, serialization
Autocser
AutoCSer is a high-performance RPC framework. AutoCSer 是一个以高效率为目标向导的整体开发框架。主要包括 TCP 接口服务框架、TCP 函数服务框架、远程表达式链组件、前后端一体 WEB 视图框架、ORM 内存索引缓存框架、日志流内存数据库缓存组件、消息队列组件、二进制 / JSON / XML 数据序列化 等一系列无缝集成的高性能组件。
Stars: ✭ 140 (-21.35%)
Mutual labels: json, serialization
Poison
An incredibly fast, pure Elixir JSON library
Stars: ✭ 1,898 (+966.29%)
Mutual labels: json, json-parser
- Turn Python objects into dicts or (json)strings
- No changes required to your objects
- Easily customizable and extendable
💗 this lib? Leave a ★ and tell your colleagues!
Example of a model to serialize:
>>> @dataclass
... class Person:
... name: str
... birthday: datetime
...
>>> p = Person('Guido van Rossum', birthday_guido)
Example of using jsons to serialize:
>>> out = jsons.dump(p)
>>> out
{'birthday': '1956-01-31T12:00:00Z', 'name': 'Guido van Rossum'}
Example of using jsons to deserialize:
>>> p2 = jsons.load(out, Person)
>>> p2
Person(name='Guido van Rossum', birthday=datetime.datetime(1956, 1, 31, 12, 0, tzinfo=datetime.timezone.utc))
Installation
pip install jsons
Usage
import jsons
some_instance = jsons.load(some_dict, SomeClass) # Deserialization
some_dict = jsons.dump(some_instance) # Serialization
In some cases, you have instances that contain other instances that need (de)serialization, for instance with lists or dicts. You can use the
typing
classes for this as is demonstrated below.
from typing import List, Tuple
import jsons
# For more complex deserialization with generic types, use the typing module
list_of_tuples = jsons.load(some_dict, List[Tuple[AClass, AnotherClass]])
(For more examples, see the FAQ)
Documentation
Meta
Recent updates
1.4.0
- Feature: DefaultDicts can now be deserialized.
- Feature: Dicts with any (hashable) key can now be dumped and loaded.
- Feature: Suppress specific warnings.
- Bugfix: Loading a verbose-serialized object in a list could sometimes deserialize that object as a parent class.
- Bugfix: Unwanted stringification of NoneValues is now prevented in Optionals and Unions with NoneType.
- Bugfix: Fixed a bug with postponed annotations and dataclasses. See also Issue34776.
- Bugfix: Types of attributes that are not in the constructor are now looked for in annotations.
1.3.1
- Bugfix: Fixed bug where classmethods were included in the serialized result.
1.3.0
- Feature: Added
warn_on_fail
parameter todefault_list_deserializer
that allows to continue deserialization upon errors. - Feature: Added
transform
that can transform an object to an object of another type. - Feature: Added serializer and deserializer for
pathlib.Path
(thanks to alexmirrington). - Change: When loading a list fails, the error message now points to the failing index.
- Bugfix: Fixed bug when dumping an object with an innerclass.
1.2.0
- Bugfix: Fixed bug with postponed typehints (PEP-563).
- Bugfix: Loading an invalid value targeting an optional did not raise.
- Bugfix: Loading a dict did not properly pass key_transformers.
- Bugfix: Loading a namedtuple did not properly use key_transformers.
- Bugfix: Utilized
__annotations__
in favor_field_types
because of deprecation as of 3.8.
1.1.2
- Feature: Added
__version__
which can be imported fromjsons
- Bugfix: Dumping a tuple with ellipsis failed in strict mode.
1.1.1
- Feature: Added a serializer for
Union
types. - Change: Exceptions are more clear upon deserialization failure (thanks to haluzpav).
- Change: You can no longer announce a class with a custom name.
- Bugfix: Fixed dumping optional attributes.
- Bugfix: Dataclasses inheriting from
JsonSerializable
always dumped their attributes as if in strict mode.
1.1.0
- Feature: Added
strict
parameter todump
to indicate that dumping a certaincls
will ignore any extra data. - Feature: When using
dump(obj, cls=x)
,x
can now be any class (previously, only a class with__slots__
). - Feature: Support for dumping
Decimal
(thanks to herdigiorgi). - Feature: Primitives are now cast if possible when dumping (e.g.
dump(5, str)
). - Feature: Dumping iterables with generic types (e.g.
dump(obj, List[str])
) will now dump with respect to that types (ifstrict
) - Feature: The
default_dict
serializer now optionally accepts types:Optional[Dict[str, type]]
. - Change: Improved performance when dumping using
strict=True
(up to 4 times faster!). - Bugfix:
set_validator
with multiple types did not work.
1.0.0
- Feature: Added a serializer/deserializer for
time
. - Feature: Added a serializer/deserializer for
timezone
. - Feature: Added a serializer/deserializer for
timedelta
. - Feature: Added a serializer/deserializer for
date
. - Bugfix: Dumping verbose did not store the types of dicts (
Dict[K, V]
). - Bugfix: Loading with
List
(no generic type) failed. - Bugfix: Loading with
Dict
(no generic type) failed. - Bugfix: Loading with
Tuple
(no generic type) failed.
Contributors
Special thanks to the following contributors of code, discussions or suggestions:
georgeharker, aecay, bibz, thijss, alexmirrington, tirkarthi, marksomething, herdigiorgi, jochembroekhoff, robinklaassen, ahmetkucuk, casparjespersen, cypreess, gastlich, jmolinski, haluzpav, finetuned89
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].