๐Ÿ”Œ Application Programming Interface

๐Ÿ”Œ Application Programming Interface#

JSON Data reader.

class JSONDataReader#

Bases: object

JSON Data reader.

Example

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

Get an iterator over the supported extensions.

Returns:

An iterator over the supported extensions

Return type:

Iterator[str]

classmethod read(data_file)#

Read a JSON data file.

Parameters:

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

Returns:

The data.

Return type:

Mapping[str, object]

register()#

Register an instance of a JSON data reader.

Return type:

None