Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Declarative JSON data parsing pipeline

Project description


Cross-language declarative parsing pipeline.


| Node: ``npm i crispum --save``
| Python: ``pip install crispum``, or if you're clever
``pipenv install crispum``


Crispum is designed to take in static JSON schema objects and return
back a parser function which will apply all of the transformations
listed in the schema object.

Here is an example of a simple
`obstruction <>`__ example.

.. code:: json

"type": "simple",
"keys": {
"indeed": "awesome"

This schema would transform the following object...

.. code:: json

"awesome": "it works!"


.. code:: json

"indeed": "it works!"

The schema may also be an array of instructions, and can apply
instructions to to the whole object or to each element of an array.

.. code:: json

"type": "pluck",
"key": "indeed"
}, {
"type": "array"
}, {
"type": "conditional",
"key": "foo",
"default": {
"type": "filter"
"options": {
"bar": {
"type": "pluck",
"key": "nested"
"baz": {
"type": "pluck",
"key": "special"
}, {
"type": "dearray"
}, {
"type": "simple",
"keys": {
"result": "0",
"extra": "1"

This results in a complex multistep schema, which when appled to data
like this...

.. code:: json

"extra": "oh hey",
"indeed": [{
"foo": "bar",
"nested": "value"
}, {
"foo": "boozle",
"nested": "lost in space"
}, {
"foo": "baz",
"nested": "value",
"special": "so bazzy"

results in...

.. code:: json

"result": "value",
"extra": "so bazzy"


``crispum(schema)`` -> ``function (data)``

Create a new crispum parser with the options passed. The returned parse
method takes one parameter, which is input data, and returns the
transformed data.


| *Required*
| Type: ``object`` or ``array``

The schema may either be a single instruction or an array of them. Each
instruction must have a ``type``, and may optionally contain an
``array`` field.

When ``array`` is true, the current data will be reinterpreted as an
array and each instruction will execute on the entries instead of the
list itself.

Available types are...


The array instruction tells the crispum pipeline to run all subsequent
instructions as if they had ``array: true`` set. It also can take in an
optional parameters, ``keys``

``keys`` is a list of keys to copy from the data into each element of
the array before continuing on the pipeline


The conditional instruction looks at the value of a specified key and
then executes a different instruction based on the value found.

- ``key``: They keyname to check the conditional against
- ``default``: The default instruction if the value found is not in the
options list
- ``options``: An associative array of instruction options


Stops an array pipeline and goes back to interpreting the data as a
whole instead of each element.


This instruction deletes the current data and does ont take any
parameters. This is useful in combination with ``array`` and


Simple onyl takes 1 other parameter, which is ``keys``. Keys should be a
valid `obstruction
schema <>`__.
The result is the same as the output obstruction would generate, except
extra keys not mentioned in the schema are not removed.


The pluck instruction takes a given key and rebases the dataset onto it.
It takes in two parameters \* ``key``: The keyname to grab and rebase
the current dataset onto \* ``keys``: An array of extra keys to copy
from the parent object into the plucked value



Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
crispum-0.2.0-py2-none-any.whl (7.7 kB) Copy SHA256 hash SHA256 Wheel py2 Jun 28, 2017
crispum-0.2.0-py3-none-any.whl (7.7 kB) Copy SHA256 hash SHA256 Wheel py3 Jun 28, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page