A Python package for loading and manipulating Docassemble-generated JSON files.
- From within Docassemble, select Package Management from the dropdown menu.
- In GitHub URL, enter the url for this repository:
https://github.com/hzerrad/docassemble-jsonloader
- Select
master
as branch, and hit Update.
- Clone this repo to your local machine using
https://github.com/hzerrad/docassemble-jsonloader
- Select
master
as branch, and hit Update.
- Once installed, you can start using JsonLoader in your docassemble by importing it:
update and install this package first
from jsonloader import JsonLoader
- Loads and parses Docassemble-generated JSON files into Python objects.
- Ability to access each element using Python conventions
- Accessing third collection:
myjson.collections[2]
- Getting a specific attribute from a form:
myjson.collections[0].title # or myjson.collections[0]['title']
- Manipulate record information (add, update, remove).
- Save as new raw JSON file.
Import package
from jsonloader import JsonLoader
Load JSON file
myjson = JsonLoader('path/to/file.json')
Extract and manipulate records
# Get all forms
forms = myjson.forms
# Get number of forms available
forms.size()
# Get sectionSelector of a record
for c in myjson.collections:
print(c.sectionSelector)
# Get collections by their sectionSelector
evidences = myjson.collections.filter('evidence')
# Add a new record
evidences[1].myrecord = 'My record'
# or evidences[1]['myrecord'] = 'My record'
# Update a record
evidences[0].myrecord = 'My New Record'
# or evidences[0]['myrecord'] = 'My New Record'
# Delete a record
del evidences[0].myrecord
# or del evidences[0]['myrecord']
- MIT license
- Copyright 2020 © Houssem Eddine Zerrad