Package for map and parse JSON text to python dict.
For example, to bring to readable form of responses from the Rest API.
# Usage example
Suppose we have such a terrible JSON dump:
```python
{
"ApiResponse": {
"ApiResponseWrapper": {
"HotelsResponse": [
{
"Country": "Russia",
"HotelId": "1234",
"HotelName": "Space Hotel",
"Photos": [
{
"BigUrl": "http://www.image.url.com",
"ThumbnailUrl": "http://www.image.url.com"
},
... other photos ...
],
"RoomsResponse": [
{
"BedsCount": "1",
"RoomId": "12312"
},
... other rooms ...
]
},
... other hotels ...
],
"ResponseTimestamp": "2342423423423423",
"SessionId": "0ABAA840-F6EC-6913-A1C2-7341899060B6"
},
"SomeProperty": "SomeData"
}
}
```
Example to map the his pretty:
```python
import json
from json_mapper.mapper import map_json
json_data = json.loads(open('dump.json').read())
mapping_config = {
'ApiResponse.ApiResponseWrapper': {
'ResponseTimestamp': 'last_update',
'{loop=>hotels} HotelsResponse': {
'HotelId': 'id',
'Country': 'country',
'{loop=>photos} Photos': 'BigUrl',
'{loop=>rooms} RoomsResponse': {
'RoomId': 'id',
'BedsCount': 'beds'
}
}
}
}
result = map_json(mapping_config, json_data)
>>> pprint(result)
{'hotels': [{'country': u'Russia',
'id': u'1234',
'photos': [u'http://www.image.url.com',
u'http://www.image.url.com'],
'rooms': [{'beds': u'1', 'id': u'12312'},
{'beds': u'1', 'id': u'12312'}]},
{'country': u'Russia',
'id': u'1234',
'photos': [u'http://www.image.url.com',
u'http://www.image.url.com'],
'rooms': [{'beds': u'1', 'id': u'12312'},
{'beds': u'1', 'id': u'12312'}]}],
'last_update': u'2342423423423423'}
```
See full example in tests directory.
Metadata
Release files for json-mapper 0.1.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json-mapper-0.1.15.tar.gz | 4.3 kB | Without provenance | Details for json-mapper-0.1.15.tar.gz |
Release files / json-mapper-0.1.15.tar.gz
| Download URL | json-mapper-0.1.15.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3fbe6f73e950b78b398b44b702342b2a7c55573b2471c63d801ec9a8a9e30dc2
|
|
BLAKE2b-256 checksum How to use checksums |
f96360bfc68587216774a788e31f87cbbe81e478a09abbf1afad28ee8dc4c08d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for json-mapper 0.1.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.