https://github.com/dev360/jsonaut
Create JSON /your/ way
https://github.com/dev360/jsonaut
Last synced: 4 months ago
JSON representation
Create JSON /your/ way
- Host: GitHub
- URL: https://github.com/dev360/jsonaut
- Owner: dev360
- Created: 2011-07-15T02:20:22.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2011-07-15T03:01:24.000Z (almost 15 years ago)
- Last Synced: 2025-11-27T10:45:31.429Z (7 months ago)
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
__ ______ ______ __ __ ______ __ __ ______
/\ \ /\ ___\ /\ __ \ /\ "-.\ \ /\ __ \ /\ \/\ \ /\__ _\
_\_\ \ \ \___ \ \ \ \/\ \ \ \ \-. \ \ \ __ \ \ \ \_\ \ \/_/\ \/
/\_____\ \/\_____\ \ \_____\ \ \_\\"\_\ \ \_\ \_\ \ \_____\ \ \_\
\/_____/ \/_____/ \/_____/ \/_/ \/_/ \/_/\/_/ \/_____/ \/_/
Just a little utlity I wrote to convert objects to JSON in fewer lines of code.
Uses simplejson, and works with Django.
>>> from jsonaut import to_json
>>>
>>> manufacturer = Manufacturer(name='Apple', website='http://www.apple.com')'
>>> category = Category(name='Laptops')
>>> product = Product(name='MacBook Pro', \
>>> category=category, \
>>> manufacturer=manufacturer)
>>>
>>> json = to_json(product, fields=['name',
>>> ('category.name', 'category_name'),
>>> {'manufacturer': ['name', 'website']}
>>> ])
{'name': 'MacBook Pro', 'category_name': 'Laptops', 'manufacturer': {'name':
'Apple', 'website': 'http://www.apple.com'}}