From 6c9be31eb02e6d9776b40e54410e156408222b8c Mon Sep 17 00:00:00 2001 From: roll Date: Mon, 7 Jul 2025 12:32:44 +0100 Subject: [PATCH 1/2] feat: JSON Data resource --- content/docs/standard/data-resource.mdx | 40 +++++++++++++++++++++++++ content/docs/standard/glossary.mdx | 16 ++++++++++ profiles/dictionary/resource.yaml | 10 +++++++ public/profiles/2.1/datapackage.json | 12 +++++++- public/profiles/2.1/dataresource.json | 12 +++++++- 5 files changed, 88 insertions(+), 2 deletions(-) diff --git a/content/docs/standard/data-resource.mdx b/content/docs/standard/data-resource.mdx index c9fb176a..6c176754 100644 --- a/content/docs/standard/data-resource.mdx +++ b/content/docs/standard/data-resource.mdx @@ -148,6 +148,7 @@ If `path` property is not provided but there is a `url` property as was defined A Data Resource descriptor `MAY` contain a property `type` that `MUST` be a string with the following possible values: - `table`: indicates that the resource is tabular as per [Tabular Data](/standard/glossary/#tabular-data) definition. Please read more about [Tabular Resource](#tabular) properties. +- `json`: indicates that the resource is JSON as per [JSON Data](/standard/glossary/#json-data) definition. Please read more about [JSON Resource](#json) properties. If property `type` is not provided, the resource is considered to be a non-specific file. An implementation `MAY` provide some additional interfaces, for example, tabular, to non-specific files if `type` can be detected from the data source or format. @@ -211,6 +212,10 @@ List of licenses as for [Data Package](/standard/data-package/#licenses). If not The properties below are applicable to any Tabular Data Resource. +#### `type` {#tabular-type} + +A Tabular Data Resource descriptor `SHOULD` contain a property `type` that `MUST` be `table`. + #### `path` or `data` [required] {#tabular-path-or-data} If the `path` property is used for providing data than it `MUST` contain [Tabular Data](/standard/glossary/#tabular-data). @@ -275,3 +280,38 @@ An example of a resource with a schema: } } ``` + +### JSON + +The properties below are applicable to any JSON Data Resource. + +#### `type` {#json-type} + +A JSON Data Resource descriptor `SHOULD` contain a property `type` that `MUST` be `json`. + +#### `path` or `data` [required] {#json-path-or-data} + +If the `path` property is used for providing data than it `MUST` contain [JSON Data](/standard/glossary/#json-data). + +If the `data` property is used for providing data for a JSON Data Resource than it `MUST` be an inline instance of [JSON Data](/standard/glossary/#json-data). + +#### `jsonSchema` + +A JSON Data Resource `MAY` have a `jsonSchema` property to provide a JSONSchema of the resource data. If provided, the `jsonSchema` property `MUST` be a valid [JSON Schema](https://json-schema.org) descriptor in a form of an object or [URL-or-Path](/standard/glossary/#url-or-path). + +An example of a resource with a JSON Schema: + +```json +{ + "name": "data", + "type": "table", + "path": "data.json", + "jsonSchema": { + "type": "object", + "properties": { + "first_name": { "type": "string" }, + "last_name": { "type": "string" } + } + } +} +``` diff --git a/content/docs/standard/glossary.mdx b/content/docs/standard/glossary.mdx index dfaf8e0a..b5aa8090 100644 --- a/content/docs/standard/glossary.mdx +++ b/content/docs/standard/glossary.mdx @@ -134,6 +134,22 @@ In JSON, a table would be: ] ``` +### JSON Data + +JSON data is a valid [JSON](https://www.json.org) object. For example: + +```json +{ + "name": "John Doe", + "age": 30, + "address": { + "street": "123 Main St", + "city": "Anytown", + "state": "CA" + } +} +``` + ### Data Representation In order to talk about the representation and processing of tabular data from text-based sources, it is useful to introduce the concepts of the _physical_ and the _logical_ representation of data. diff --git a/profiles/dictionary/resource.yaml b/profiles/dictionary/resource.yaml index 76f6947e..e639fe97 100644 --- a/profiles/dictionary/resource.yaml +++ b/profiles/dictionary/resource.yaml @@ -72,6 +72,9 @@ dataResource: schema: "$ref": "#/definitions/tableSchema" propertyOrder: 140 + jsonSchema: + "$ref": "#/definitions/jsonSchema" + propertyOrder: 140 pathArray: type: array minItems: 1 @@ -115,6 +118,7 @@ resourceType: type: string enum: - table + - json format: title: Format description: The file format of this resource. @@ -170,3 +174,9 @@ hash: { "hash": "SHA256:5262f12512590031bbcc9a430452bfd75c2791ad6771320bb4b5728bfb78c4d0" } +jsonSchema: + title: JSON schema + description: A JSON Schema for this resource, compliant with the JSON Schema specification. + type: + - string + - object diff --git a/public/profiles/2.1/datapackage.json b/public/profiles/2.1/datapackage.json index dac04f0b..c3abdffb 100644 --- a/public/profiles/2.1/datapackage.json +++ b/public/profiles/2.1/datapackage.json @@ -323,7 +323,8 @@ "propertyOrder": 235, "type": "string", "enum": [ - "table" + "table", + "json" ] }, "title": { @@ -3404,6 +3405,15 @@ "examples": [ "{\n \"schema\": {\n \"fields\": [\n {\n \"name\": \"first_name\",\n \"type\": \"string\"\n \"constraints\": {\n \"required\": true\n }\n },\n {\n \"name\": \"age\",\n \"type\": \"integer\"\n },\n ],\n \"primaryKey\": [\n \"name\"\n ]\n }\n}\n" ] + }, + "jsonSchema": { + "propertyOrder": 140, + "title": "JSON schema", + "description": "A JSON Schema for this resource, compliant with the JSON Schema specification.", + "type": [ + "string", + "object" + ] } } }, diff --git a/public/profiles/2.1/dataresource.json b/public/profiles/2.1/dataresource.json index 89cb50fc..e00f484a 100644 --- a/public/profiles/2.1/dataresource.json +++ b/public/profiles/2.1/dataresource.json @@ -87,7 +87,8 @@ "propertyOrder": 235, "type": "string", "enum": [ - "table" + "table", + "json" ] }, "title": { @@ -3168,6 +3169,15 @@ "examples": [ "{\n \"schema\": {\n \"fields\": [\n {\n \"name\": \"first_name\",\n \"type\": \"string\"\n \"constraints\": {\n \"required\": true\n }\n },\n {\n \"name\": \"age\",\n \"type\": \"integer\"\n },\n ],\n \"primaryKey\": [\n \"name\"\n ]\n }\n}\n" ] + }, + "jsonSchema": { + "propertyOrder": 140, + "title": "JSON schema", + "description": "A JSON Schema for this resource, compliant with the JSON Schema specification.", + "type": [ + "string", + "object" + ] } } } \ No newline at end of file From 8ff5897b6075e8eead12f397413381a00a82017e Mon Sep 17 00:00:00 2001 From: roll Date: Mon, 21 Jul 2025 08:22:10 +0100 Subject: [PATCH 2/2] Fixed minor issues --- content/docs/standard/data-resource.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/docs/standard/data-resource.mdx b/content/docs/standard/data-resource.mdx index 6c176754..70d96a56 100644 --- a/content/docs/standard/data-resource.mdx +++ b/content/docs/standard/data-resource.mdx @@ -297,20 +297,20 @@ If the `data` property is used for providing data for a JSON Data Resource than #### `jsonSchema` -A JSON Data Resource `MAY` have a `jsonSchema` property to provide a JSONSchema of the resource data. If provided, the `jsonSchema` property `MUST` be a valid [JSON Schema](https://json-schema.org) descriptor in a form of an object or [URL-or-Path](/standard/glossary/#url-or-path). +A JSON Data Resource `MAY` have a `jsonSchema` property to provide a JSON Schema of the resource data. If provided, the `jsonSchema` property `MUST` be a valid [JSON Schema](https://json-schema.org) descriptor in a form of an object or [URL-or-Path](/standard/glossary/#url-or-path). An example of a resource with a JSON Schema: ```json { "name": "data", - "type": "table", + "type": "json", "path": "data.json", "jsonSchema": { "type": "object", "properties": { - "first_name": { "type": "string" }, - "last_name": { "type": "string" } + "givenName": { "type": "string" }, + "familyName": { "type": "string" } } } }