Skip to content

Commit 6c9be31

Browse files
committed
feat: JSON Data resource
1 parent 53477c7 commit 6c9be31

5 files changed

Lines changed: 88 additions & 2 deletions

File tree

content/docs/standard/data-resource.mdx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ If `path` property is not provided but there is a `url` property as was defined
148148
A Data Resource descriptor `MAY` contain a property `type` that `MUST` be a string with the following possible values:
149149

150150
- `table`: indicates that the resource is tabular as per [Tabular Data](/standard/glossary/#tabular-data) definition. Please read more about [Tabular Resource](#tabular) properties.
151+
- `json`: indicates that the resource is JSON as per [JSON Data](/standard/glossary/#json-data) definition. Please read more about [JSON Resource](#json) properties.
151152

152153
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.
153154

@@ -211,6 +212,10 @@ List of licenses as for [Data Package](/standard/data-package/#licenses). If not
211212

212213
The properties below are applicable to any Tabular Data Resource.
213214

215+
#### `type` {#tabular-type}
216+
217+
A Tabular Data Resource descriptor `SHOULD` contain a property `type` that `MUST` be `table`.
218+
214219
#### `path` or `data` [required] {#tabular-path-or-data}
215220

216221
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:
275280
}
276281
}
277282
```
283+
284+
### JSON
285+
286+
The properties below are applicable to any JSON Data Resource.
287+
288+
#### `type` {#json-type}
289+
290+
A JSON Data Resource descriptor `SHOULD` contain a property `type` that `MUST` be `json`.
291+
292+
#### `path` or `data` [required] {#json-path-or-data}
293+
294+
If the `path` property is used for providing data than it `MUST` contain [JSON Data](/standard/glossary/#json-data).
295+
296+
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).
297+
298+
#### `jsonSchema`
299+
300+
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).
301+
302+
An example of a resource with a JSON Schema:
303+
304+
```json
305+
{
306+
"name": "data",
307+
"type": "table",
308+
"path": "data.json",
309+
"jsonSchema": {
310+
"type": "object",
311+
"properties": {
312+
"first_name": { "type": "string" },
313+
"last_name": { "type": "string" }
314+
}
315+
}
316+
}
317+
```

content/docs/standard/glossary.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ In JSON, a table would be:
134134
]
135135
```
136136

137+
### JSON Data
138+
139+
JSON data is a valid [JSON](https://www.json.org) object. For example:
140+
141+
```json
142+
{
143+
"name": "John Doe",
144+
"age": 30,
145+
"address": {
146+
"street": "123 Main St",
147+
"city": "Anytown",
148+
"state": "CA"
149+
}
150+
}
151+
```
152+
137153
### Data Representation
138154

139155
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.

profiles/dictionary/resource.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ dataResource:
7272
schema:
7373
"$ref": "#/definitions/tableSchema"
7474
propertyOrder: 140
75+
jsonSchema:
76+
"$ref": "#/definitions/jsonSchema"
77+
propertyOrder: 140
7578
pathArray:
7679
type: array
7780
minItems: 1
@@ -115,6 +118,7 @@ resourceType:
115118
type: string
116119
enum:
117120
- table
121+
- json
118122
format:
119123
title: Format
120124
description: The file format of this resource.
@@ -170,3 +174,9 @@ hash:
170174
{
171175
"hash": "SHA256:5262f12512590031bbcc9a430452bfd75c2791ad6771320bb4b5728bfb78c4d0"
172176
}
177+
jsonSchema:
178+
title: JSON schema
179+
description: A JSON Schema for this resource, compliant with the JSON Schema specification.
180+
type:
181+
- string
182+
- object

public/profiles/2.1/datapackage.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@
323323
"propertyOrder": 235,
324324
"type": "string",
325325
"enum": [
326-
"table"
326+
"table",
327+
"json"
327328
]
328329
},
329330
"title": {
@@ -3404,6 +3405,15 @@
34043405
"examples": [
34053406
"{\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"
34063407
]
3408+
},
3409+
"jsonSchema": {
3410+
"propertyOrder": 140,
3411+
"title": "JSON schema",
3412+
"description": "A JSON Schema for this resource, compliant with the JSON Schema specification.",
3413+
"type": [
3414+
"string",
3415+
"object"
3416+
]
34073417
}
34083418
}
34093419
},

public/profiles/2.1/dataresource.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"propertyOrder": 235,
8888
"type": "string",
8989
"enum": [
90-
"table"
90+
"table",
91+
"json"
9192
]
9293
},
9394
"title": {
@@ -3168,6 +3169,15 @@
31683169
"examples": [
31693170
"{\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"
31703171
]
3172+
},
3173+
"jsonSchema": {
3174+
"propertyOrder": 140,
3175+
"title": "JSON schema",
3176+
"description": "A JSON Schema for this resource, compliant with the JSON Schema specification.",
3177+
"type": [
3178+
"string",
3179+
"object"
3180+
]
31713181
}
31723182
}
31733183
}

0 commit comments

Comments
 (0)