๐Ÿ”Œ Application Programming Interface

๐Ÿ”Œ Application Programming Interface#

galactic.io.data.json module

Class


class JSONDataReader#

Bases: object

JSON Data reader.

Example

>>> from pprint import pprint
>>> from galactic.io.data.json import JSONDataReader
>>> reader = JSONDataReader()
>>> import io
>>> text = '''
... {
... "#1": {
...     "name": "Galois",
...     "firstname": "ร‰variste"
...   },
... "#2": {
...     "name": "Wille",
...     "firstname": "Rudolf"
...   }
... }
... '''
>>> data = reader.read(io.StringIO(text))
>>> pprint(data)
{'#1': frozendict.frozendict({'name': 'Galois', 'firstname': 'ร‰variste'}),
 '#2': frozendict.frozendict({'name': 'Wille', 'firstname': 'Rudolf'})}
extensions()#

Get an iterator over the supported extensions.

Returns:

An iterator over the supported extensions

Return type:

Iterator[str]

read(data_file)#

Read a JSON data file.

Parameters:

data_file (TextIO) โ€“ A readable text file.

Returns:

The data.

Return type:

Data

Raises:

TypeError โ€“ If the JSON data is not a list or a dict

register()#

Register an instance of a JSON data reader.

Return type:

None