Skip to main content

DRB json driver

Project description

JsonNode Implementation

This drb-driver-json module implements json format access with DRB data model. It is able to navigates among the json contents.

Json Factory and Json Node

The module implements the basic factory model defined in DRB in its node resolver. Based on the python entry point mechanism, this module can be dynamically imported into applications.

The entry point group reference is drb.driver.
The driver name is json.
The factory class JsonNodeFactory is encoded into drb.drivers.json.factory.

The json factory creates a JsonNode from an existing json content. It uses a base node to access the content data using the streamed base node implementation.

The base node can be a FileNode (See drb), HttpNode, ZipNode or any other node able to provide streamed (BufferedIOBase, RawIOBase, IO) json content.

limitations

The current version does not manage child modification and insertion. JsonNode is currently read only.

Using this module

To include this module into your project, the drb-driver-json module shall be referenced into requirement.txt file, or the following pip line can be run:

pip install drb-driver-json

Node Creation:

The driver can create a JsonNode by giving the path to a json file:

from drb.drivers.json import DrbJsonNode

node = JsonNode(PATH_JSON)

the driver can also give a dictionary in argument:

from drb.drivers.json import DrbJsonNode

DICT = { 
        "id":"01", 
        "name": "Tom", 
        "lastname": "Price" 
     }
node = JsonNode(NAME_OF_YOUR_NODE, data = DICT)

If the baseNode is an HttpNode, FileNode... the driver can retrieve the data of your Json with this:

from drb.drivers.json import JsonNodeFactory

FACTORY = JsonNodeFactory()
FILE_NODE = DrbFileNode(PATH_TO_YOUR_JSON)
NODE = FACTORY.create(FILE_NODE)

Different types of data

data JSON Type Python Type
null null None
true/false boolean bool
'hello World' string str
1 int int
1.0 number float
[...] array list
{...} object dict

Documentation

The documentation of this driver can be found here https://drb-python.gitlab.io/impl/json

Project details


Download files

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

Source Distribution

drb-driver-json-1.3.0.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

drb_driver_json-1.3.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file drb-driver-json-1.3.0.tar.gz.

File metadata

  • Download URL: drb-driver-json-1.3.0.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.18

File hashes

Hashes for drb-driver-json-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c931b8789c3e90f6b8cf6b3f576d7ae3c473ba3f6f8044d1997f5d94c7fd152b
MD5 43c609dbe31187b17477be2b5983adbf
BLAKE2b-256 46aa042d51bb98c574fbf50840281fa208a6549f6f4af9410365ecd8dcbc7bb8

See more details on using hashes here.

File details

Details for the file drb_driver_json-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for drb_driver_json-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f78f2e9df08a0b448c8ad2e7f76d3d5a6b00e118299ea94f7fc35ecf08e90b32
MD5 28d43ff7f03a27e439433effdf4017b6
BLAKE2b-256 414204109aaae0eb37a8f7b8b23e348e28e1bc4ccbeb314c53f54b6d4c902042

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page