Skip to content

A Python package for loading Docassemble-generated JSON files.

License

Notifications You must be signed in to change notification settings

hzerrad/docassemble-jsonloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docassemble JsonLoader

A Python package for loading and manipulating Docassemble-generated JSON files.

Build Status License

Installation

  • 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

  • Clone this repo to your local machine using https://github.com/hzerrad/docassemble-jsonloader
  • Select master as branch, and hit Update.

Setup

  • Once installed, you can start using JsonLoader in your docassemble by importing it:

update and install this package first

from jsonloader import JsonLoader

Features

  • 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.

Usage

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'] 

License

License

About

A Python package for loading Docassemble-generated JSON files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages