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.1.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file drb_driver_json-1.3.1.tar.gz.

File metadata

  • Download URL: drb_driver_json-1.3.1.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for drb_driver_json-1.3.1.tar.gz
Algorithm Hash digest
SHA256 ad4d3c3899f80ba8750c66e1adaae5658780a2e419dda1516ec35483a7f26616
MD5 584d34ed7e2bc2b326ef0c98524c1473
BLAKE2b-256 187d1c2a8670e843b764a6ec0aee83b57751d8245e4d0febdcd54026a4858985

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for drb_driver_json-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0493b7be52943ed6dcfd48c883c3ee7437487a37c1610825b10e21064d598485
MD5 4b0ec68f5ff5a3d033cb2c8e640f0c26
BLAKE2b-256 4b4117a90a620f83de66c679425a3719c5c8ffd4e83df9756adff8098e18eb3e

See more details on using hashes here.

Supported by

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