You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the contents of a `codemeta.json` file into the bottom box, and click the
33
+
`Validate codemeta.json` button.
9
34
10
35
## Creating a CodeMeta instance file manually
11
36
12
-
A CodeMeta instance file describes the metadata associated with a software object using JSON's linked data (JSON-LD) notation. A CodeMeta file can contain any of the properties described on the [CodeMeta terms page](/terms/). Most CodeMeta files are called `codemeta.json` by convention.
37
+
A CodeMeta instance file describes the metadata associated with a software
38
+
object using JSON's linked data (JSON-LD) notation. A CodeMeta file can
39
+
contain any of the properties described on the [CodeMeta terms page](terms).
13
40
14
-
Here is an example of a basic `codemeta.json` that you can put at the root of a GitHub repo
15
-
([link to full example](https://github.com/gem-pasteur/macsyfinder/blob/master/codemeta.json)):
41
+
Any plaintext or code editor is sufficient for creating a CodeMeta instance
42
+
file. An editor that has syntax highlighting for `JSON` can assist by
Most CodeMeta files are called `codemeta.json` by convention. While other
46
+
filenames are valid, they will be less recognisable and may be overlooked.
47
+
{.tip}
48
+
49
+
### Understanding JSON and JSON-LD
34
50
35
-
### Basics
51
+
CodeMeta files contain JSON *key-value pairs*, sometimes referred to as
52
+
*name-value pairs* where the values can be *simple values*, *arrays*, or *JSON
53
+
objects*. Key-value pairs are known as *property-value pairs* in JSON-LD
54
+
linked-data.
36
55
37
-
When creating a CodeMeta document, note that they contain JSON name ("property" in linked-data), value pairs where the values can be simple values, arrays or JSON objects. A simple value is a number, string, or one the literal values *false*, *null**true*, for example:
56
+
#### Simple Values
57
+
58
+
A simple value is a number, string, or one the literal values *false*, *null*
59
+
*true*. For example:
38
60
39
61
```json
40
62
"name" : "R Interface to the DataONE REST API"
41
63
```
42
64
43
-
There must be a comma between of these key-value pairs, and no comma at the end before the closing bracket (`}`).
65
+
Key-value pairs must be separated by a comma. There must be no comma at the
66
+
end before the closing brace (`}`).
44
67
45
-
### Arrays
68
+
####Arrays
46
69
47
-
A JSON array is surrounded by the characters `[` and `]`, and can contain multiple values separated by commas:
70
+
A JSON array is surrounded by parentheses; `[` and `]`. Arrays can contain
As with any JSON documents, you can add line breaks between values for improved quality. For example, the former key-value pair is this is equivalent to:
77
+
Arrays should contain line breaks between values and indenting (spaces at the
78
+
start of a line). These make the data easier for humans to read. The above
79
+
example is equivalent to:
54
80
55
81
```json
56
82
"keywords": [
@@ -60,7 +86,9 @@ As with any JSON documents, you can add line breaks between values for improved
60
86
]
61
87
```
62
88
63
-
All fields that accept a value of a given type accept an array of values of this type, and vice-versa. For example, a software with two licenses could have this attribute:
89
+
Fields that accept a value of a given type will accept an array of values of
90
+
that type. For example, a software with two licenses could have this
91
+
attribute:
64
92
65
93
```json
66
94
"license": [
@@ -69,9 +97,11 @@ All fields that accept a value of a given type accept an array of values of this
69
97
]
70
98
```
71
99
72
-
### Objects
100
+
####Objects
73
101
74
-
Some properties, such as `author`, can refer to other JSON objects surrounded by curly braces and can contain other JSON values or objects, for example:
102
+
Some properties, such as `author`, can refer to other JSON objects. Objects
103
+
are surrounded by braces; `{` and `}`. These can contain other JSON values or
104
+
objects. For example:
75
105
76
106
```json
77
107
"author": {
@@ -83,18 +113,44 @@ Some properties, such as `author`, can refer to other JSON objects surrounded by
83
113
}
84
114
```
85
115
86
-
The JSON-LD "@type" keyword associates a JSON value or object with a well known type, for example, the
87
-
statement `"@type":"Person"` associates the `author` object with `http://schema.org/Person`.
88
-
It is good practice to always provide the `@type` for any property which specifies a node (JSON object).
89
-
The [terms page](/terms/) indicates these node types.
116
+
#### Keywords
117
+
118
+
JSON-LD has the concept of Keywords, which are properties prefaced with a `@`.
119
+
120
+
These references work similar to includes in a programming language.
121
+
{.tip}
122
+
123
+
Keywords are instructions for the processor of the file to refer to
124
+
previously stored information. This means that the exact same information can
125
+
be included multiple times, and pulled from a consistent source.
126
+
127
+
The source can be an external resource, as depicted in the diagram below:
128
+
129
+

90
130
91
-
The "author" JSON object illustrates the use of the JSON-LD keyword "@id", which is used to associate an IRI with the JSON object. Any such node object can be assigned an `@id`, and we may use the `@id` to refer to this same object (the person, Peter), elsewhere in the document; e.g. we can indicate the same individual is also the `maintainer` by adding:
131
+
The JSON-LD "@type" keyword associates a JSON value or object with a well
132
+
known type. In the previous example, the statement `"@type":"Person"`
133
+
associates the `author` object with `http://schema.org/Person`. It is good
134
+
practice to always provide the `@type` for any property which specifies a node
135
+
(JSON object). The [terms page](/terms/) indicates these node types.
136
+
137
+
Keywords also provide similiar utility to a function in a programming
138
+
language; they prompt the processor to output the same data in another place
139
+
in the file.
140
+
{.tip}
141
+
142
+
The "author" JSON object illustrates the use of the JSON-LD keyword "@id",
143
+
which is used to associate an IRI with the JSON object. Any such node object
144
+
can be assigned an `@id`, and we may use the `@id` to refer to this same
145
+
object (the person, Peter), elsewhere in the document; e.g. we can indicate
146
+
the same individual is also the `maintainer` by adding:
This should be added at the top level of the document, indicating that this individual is the `maintainer` of the software being described, like this:
152
+
This should be added at the top level of the document, indicating that this
153
+
individual is the `maintainer` of the software being described, like this:
98
154
99
155
```json
100
156
{
@@ -113,7 +169,12 @@ This should be added at the top level of the document, indicating that this indi
113
169
}
114
170
```
115
171
116
-
JSON-LD operations can later *expand* this reference and *embed* the full information at both locations. This means the example above is equivalent to:
172
+
173
+
JSON-LD operations can later *expand* this reference and *embed* the full
174
+
information at both locations.
175
+
176
+
This means the previous example is equivalent to:
177
+
117
178
118
179
```json
119
180
{
@@ -138,9 +199,10 @@ JSON-LD operations can later *expand* this reference and *embed* the full inform
138
199
}
139
200
```
140
201
141
-
### Nesting objects
202
+
####Nesting objects
142
203
143
-
We saw before a simple (root) SoftwareSourceCode object:
204
+
The following SoftwareSourceCode object is an example of a simple root
205
+
object:
144
206
145
207
```json
146
208
{
@@ -150,7 +212,8 @@ We saw before a simple (root) SoftwareSourceCode object:
150
212
}
151
213
```
152
214
153
-
and this root object can refer to other objects, for example recommend a SoftwareApplication:
215
+
A root object can refer to other objects. For example, it may recommend a
216
+
SoftwareApplication:
154
217
155
218
```json
156
219
{
@@ -165,7 +228,8 @@ and this root object can refer to other objects, for example recommend a Softwar
165
228
}
166
229
```
167
230
168
-
And you may in turn want to add attributes to this application:
231
+
Nesting can go many layers deep. In this example, to add attributes to this
232
+
application:
169
233
170
234
```json
171
235
{
@@ -185,9 +249,22 @@ And you may in turn want to add attributes to this application:
185
249
}
186
250
```
187
251
188
-
It is important to mind the order of curly brackets (an object begins with a `{` and ends with a matching `}`) and indentation (spaces at the beginning of a line) to reflect the hierarchy: "Central R Archive Network (CRAN)" is the name of the provider of "rmarkdown", which is a softwareSuggestions of CodemetaR.
252
+
Indentation and matching braces are important. These reflect the hierarchy of
253
+
the document.
254
+
255
+
Each object begins with a `{` and ends with a matching `}`. Each object should
256
+
also have a depth of indentation (the spaces at the beginning of a line) that
257
+
reflects its place in the hierarchy.
258
+
259
+
This above example defines "Central R Archive Network (CRAN)" as the name of
260
+
the provider of "rmarkdown", which is a softwareSuggestions of CodemetaR.
261
+
262
+
Putting key-value or property-value pairs in a different place in the document
263
+
hierarchy can change the meaning of the document.
189
264
190
-
For example, the above code is not equivalent to:
265
+
The code below has the `"url"` pair at a different hierarchy. The result is
266
+
that it no longer belongs with the `"provider"` information, and the meaning
267
+
of the document has changed. It is *_not_* equivalent to the code above.
191
268
192
269
```json
193
270
{
@@ -207,23 +284,67 @@ For example, the above code is not equivalent to:
207
284
}
208
285
```
209
286
210
-
because in the latter, `"https://cran.r-project.org"` is the `"url"` of `rmarkdown`, instead of being the url of `Central R Archive Network (CRAN)`.
287
+
The change in hierarchy means that `"https://cran.r-project.org"` is
288
+
represented as the `"url"` of `rmarkdown`, instead of being the url of
289
+
`Central R Archive Network (CRAN)`.
290
+
291
+
### Example of a CodeMeta file
292
+
293
+
The following is an example of a basic `codemeta.json` that can be put at the
294
+
root of a code repository.
295
+
([link to full example](https://github.com/gem-pasteur/macsyfinder/blob/master/codemeta.json)):
Every CodeMeta document must refer to the context file *codemeta.jsonld*, for example via a URL. This indicates that all terms in the document should be interpreted in the "context" of CodeMeta. Most terms are chosen to match the equivalent terms in <http://schema.org>, but CodeMeta provides a few additional terms not found in <http://schema.org> which may be helpful for software projects. CodeMeta also restricts the context to use only those <https://schema.org> terms that are explicitly listed on the [terms](/terms/) page. Users wanting to include additional terms must extend the context (see [developer-guide](/developer-guide/)).
317
+
Every CodeMeta document must refer to the context file *codemeta.jsonld*, for
318
+
example via a URL. This indicates that all terms in the document should be
319
+
interpreted in the "context" of CodeMeta.
320
+
321
+
Most terms are chosen to match the equivalent terms in <http://schema.org>,
322
+
but CodeMeta provides a few additional terms not found in <http://schema.org>
323
+
which may be helpful for software projects.
324
+
325
+
CodeMeta also restricts the context to use only those <https://schema.org>
326
+
terms that are explicitly listed on the [terms](/terms/) page. Users wanting
327
+
to include additional terms must extend the context (see
328
+
[the developer guide](/developer-guide/)).
329
+
330
+
The context file may be modified and updated in the future, if new JSON
331
+
properties are added or existing ones modified.
215
332
216
-
The context file may be modified and updated in the future, if new JSON properties are added or existing ones modified.
217
-
The CodeMeta GitHub repository defines tags to allow specific versions of a file to be referenced, and assigns
218
-
*digital object identifiers*, or DOIs, to each release tag. Please use the [appropriate release](https://github.com/codemeta/codemeta/releases) of the CodeMeta schema in order to refer to the
219
-
appropriate context file, e.g.
333
+
The CodeMeta GitHub repository defines tags to allow specific versions of a
334
+
file to be referenced, and assigns *digital object identifiers*, or DOIs, to
335
+
each release tag. Please use the
336
+
[appropriate release](https://github.com/codemeta/codemeta/releases) of the
337
+
CodeMeta schema in order to refer to the appropriate context file, e.g.
220
338
221
339
```json
222
340
"@context": "https://w3id.org/codemeta/3.1"
223
341
```
224
342
225
-
Release candidate versions may be referred to consistently using their [git tag](https://github.com/codemeta/codemeta/tags) for the raw version, e.g. <https://raw.githubusercontent.com/codemeta/codemeta/2.0-rc/codemeta.jsonld>. *Please do not refer to the raw GitHub URL for the master branch*, as this is subject to change and will not guarantee a stable metadata file.
343
+
## Referencing CodeMeta
226
344
227
-
## Testing An Instance file
345
+
Release candidate versions may be referred to consistently using their
346
+
[git tag](https://github.com/codemeta/codemeta/tags) for the raw version, e.g.
*Please do not refer to the raw GitHub URL for the master branch*, as this is
349
+
/subject to change and will not guarantee a stable metadata file.
228
350
229
-
Our [codemeta-generator](https://codemeta.github.io/codemeta-generator/) can also check a codemeta.json file you wrote is valid. To do that, copy-paste your code in the bottom box, and click "Validate codemeta.json".
0 commit comments