Edit page in Livemark
(2024-01-29 13:37)

Json Resource

A json resource contains a structured data like JSON or YAML (can be validated with JSONSchema -- under development):

from frictionless.resources import JsonResource

resource = JsonResource(path='data.json')
resource.infer(stats=True)
print(resource)
{'name': 'data',
 'type': 'json',
 'path': 'data.json',
 'scheme': 'file',
 'format': 'json',
 'mediatype': 'text/json',
 'encoding': 'utf-8',
 'hash': 'sha256:80af3283a5c57e5d3a8d1d4099bebe639c610c4ecc8ce39fe53f9f9d9c441c4a',
 'bytes': 21}

We can read the contents:

from frictionless.resources import JsonResource

resource = JsonResource(path='data.json')
resource.infer(stats=True)
print(resource.read_data())
{'key': 'value'}