Changes between Version 17 and Version 18 of pyson
- Timestamp:
- 05/10/21 15:59:00 (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
pyson
v17 v18 1 == P ackson31 == Pyson 2 2 3 P ackson is a json (de)serializer for python3 objects.4 It uses annotations in the style ofjackson.3 Pyson is a json (de)serializer for python3 objects. 4 It uses some annotations inspired by jackson. 5 5 6 6 7 7 install: 8 8 {{{ 9 pip install https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/export/1 38/packson3/dist/packson3-1.0.0.tar.gz9 pip install https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/export/142/pyson/dist/pyson-1.0.0.tar.gz 10 10 }}} 11 11 12 12 or from your setup.py 13 13 {{{ 14 install_requires=[ "p ackson3@https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/export/138/packson3/dist/packson3-1.0.0.tar.gz"],14 install_requires=[ "pyson@pip install https://tracinsy.ewi.tudelft.nl/pubtrac/Utilities/export/142/pyson/dist/pyson-1.0.0.tar.gz"], 15 15 }}} 16 16 … … 21 21 == Examples 22 22 23 See [source:p ackson3/test/ObjectMapperTest.py] for many examples.23 See [source:pyson/test/ObjectMapperTest.py] for many examples. 24 24 25 25 A simple example, deserializng a dict with objects 26 26 {{{ 27 from p ackson3.ObjectMapper import ObjectMapper28 from p ackson3.JsonTypeInfo import JsonTypeInfo29 from p ackson3.JsonTypeInfo import Id,As27 from pyson.ObjectMapper import ObjectMapper 28 from pyson.JsonTypeInfo import JsonTypeInfo 29 from pyson.JsonTypeInfo import Id,As 30 30 from typing import Dict 31 31 … … 42 42 return self._name+","+str(self._a) 43 43 44 p ackson3=ObjectMapper()44 pyson=ObjectMapper() 45 45 objson = { 'a':{"Simple":{'a':1}},'c':{"Simple":{'a':3}}} 46 obj=packson3.parse(objson, Dict[str,Simple]) 46 obj=pyson.parse(objson, Dict[str,Simple]) 47 obj['a'].geta() 47 48 }}} 48 49 … … 51 52 52 53 {{{ 53 from p ackson3.ObjectMapper import ObjectMapper54 from p ackson3.JsonSubTypes import JsonSubTypes55 from p ackson3.JsonTypeInfo import JsonTypeInfo56 from p ackson3.JsonTypeInfo import Id,As54 from pyson.ObjectMapper import ObjectMapper 55 from pyson.JsonSubTypes import JsonSubTypes 56 from pyson.JsonTypeInfo import JsonTypeInfo 57 from pyson.JsonTypeInfo import Id,As 57 58 from typing import Dict,List,Set 58 59 import json … … 97 98 self._props==other._props 98 99 99 jackson=ObjectMapper()100 pyson=ObjectMapper() 100 101 101 102 102 103 obj=Bear(Props(1,'bruno')) 103 res= jackson.toJson(obj)104 res=pyson.toJson(obj) 104 105 print("result:"+str(res)) 105 106 bson={'Bear': {'props': {'age': 1, 'name': 'bruno'}}} 106 res= jackson.parse(bson, Animal)107 res=pyson.parse(bson, Animal) 107 108 print("Deserialized an Animal! -->"+str(res)) 108 109