-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple.py
More file actions
34 lines (30 loc) · 782 Bytes
/
simple.py
File metadata and controls
34 lines (30 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pprint
from preparer import FieldsPreparer
pp = pprint.PrettyPrinter(indent=4)
payload = {
'type': 'articles',
'id': '1',
'attributes': {
'title': 'JSON API paints my bikeshed!',
'body': 'The shortest article. Ever.',
'created': '2015-05-22T14:56:29.000Z',
'updated': '2015-05-22T14:56:28.000Z'
},
'relationships': {
'author': {
'data': {'id': '42', 'type': 'people'}
}
},
'tags': [
{'name': 'tag-1', 'count': 1},
{'name': 'tag-2', 'count': 2},
{'name': 'tag-3', 'count': 3},
],
}
preparer = FieldsPreparer(fields={
'id': 'id',
'type': 'type',
'title': 'attributes.title',
'body': 'attributes.body'
})
pp.pprint(preparer.prepare(payload))