JSON Import Format Specification
General information
SnippetsLab defines a JSON library format and can import data from any .json
file that conforms to the required format, as discussed below. This makes it possible to import from arbitrary third-party sources as long as they are converted to the supported format first.
The JSON format is designed to support the app’s full feature set while allowing users to use only a subset of them. For example, you can generate and import a JSON file that only contains snippets (no folders, tags, etc.). Most of the attributes are optional, with a few exceptions, which are marked as “required” in the description.
Schema
Root
Key path: (root)
Field |
Type |
Description |
---|---|---|
|
Dictionary |
A dictionary containing all folders, snippets, smart groups, tags, and shortcuts. Required. |
Contents
Key path: (root).contents
Field |
Type |
Description |
---|---|---|
|
|
An array of all root level folders. |
|
|
An array of all snippets. |
|
|
An array of all smart groups. |
|
|
An array of all tags. |
|
|
An array of all shortcuts. |
Folder
Key path: (root).contents.folders[*].
Field |
Type |
Description |
---|---|---|
|
String |
Name of the folder. |
|
String |
Unique identifier. See discussion. Required. |
|
|
An array of subfolders inside the folder. |
Snippet
Key path: (root).contents.snippets[*].
Field |
Type |
Description |
---|---|---|
|
String |
Name of the snippet. Required. |
|
String |
UUID of the folder that this snippet belongs to. |
|
|
An array of UUIDs of tags assigned to this snippet. |
|
Boolean |
Indicates whether this snippet is pinned. |
|
String |
Creation date of the snippet. See discussion. |
|
String |
Last modification date of the snippet. See discussion. |
|
|
An array of |
Fragment
Key path: (root).contents.snippets[*].fragments[*].
Field |
Type |
Description |
---|---|---|
|
String |
Name of the fragment, this is often omitted if there is only one fragment. |
|
String |
Text for the notes area. |
|
|
Rich text attributes for the notes. |
|
String |
The content of the snippet. Required. |
|
String |
Language of the fragment. See discussion. |
|
String |
Creation date of the fragment. See discussion. |
|
String |
Last modification date of the fragment. See discussion. |
Smart Group
Key path: (root).contents.smartGroups[*].
Field |
Type |
Description |
---|---|---|
|
String |
Name of the smart group. |
|
String |
Unique identifier. See discussion. Required. |
|
String |
Search predicate of the smart group. See discussion. Required. |
Tag
Key path: (root).contents.tags[*].
Field |
Type |
Description |
---|---|---|
|
String |
Name of the tag. |
|
String |
Unique identifier. See discussion. Required. |
Shortcut
Key path: (root).contents.shortcuts[*].
Field |
Type |
Description |
---|---|---|
|
String |
Unique identifier of the folder, smart group or tag that this shortcut links to. Required. |
Note Attribute
Key path: (root).contents.snippets[*].fragments[*].noteAttributes[*].
Field |
Type |
Description |
---|---|---|
|
String |
Name of the attribute, for example |
|
[Int] |
Range of this attribute, in the format of |
|
String |
An optional string value for the attribute, currently only used for the |
Discussion
UUID: In the JSON format, UUIDs are used for cross-referencing between entities. For example, each
folder
must have auuid
, whose value is then referenced by allsnippet
located within the folder. Similarly, a shortcut references the target folder, smart group, or tag with their UUID. The UUIDs do not have to conform to any specific format, but they must be unique across all UUIDs in the JSON file.Date: All dates, such as
dateCreated
anddateModified
, are formatted as strings that conform to the ISO 8601 standard. For example,2011-08-29T20:34:41Z
.Language: In a
fragment
, the language is expressed by a Pygments lexer name. See Pygments documentation for a complete list. Note that some languages listed there may not be supported by SnippetsLab.Predicate: Each
smartGroup
must have a predicate attribute indicating the search criteria. This predicate is used byNSPredicate
internally.
Example
{
"contents": {
"folders": [
{
"title": "Publishing",
"uuid": "D3F0277B-6230-46C1-9D2E-3E1B8CE509BF"
},
{
"title": "Graphic Design",
"uuid": "D42BB115-44C4-4931-ACF8-8AD5F2D1778C",
"children": [
{
"title": "Subfolder 1",
"uuid": "4D356EC0-6118-4DDE-B09C-EC4116698877",
},
{
"title": "Subfolder 2",
"uuid": "2C6E47F2-A23F-4B4D-B63E-B1C37973A7BC",
}
]
}
],
"snippets": [
{
"title": "Lorem ipsum",
"folder": "D3F0277B-6230-46C1-9D2E-3E1B8CE509BF",
"fragments": [
{
"title" : "Fragment",
"language": "MarkdownLexer",
"note": "Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"dateCreated": "2011-08-29T20:34:41Z",
"dateModified": "2011-08-29T20:34:41Z",
"uuid": "FA7BA77B-A93C-4D92-AC70-42EFF051C4D5",
}
],
"tags": [
"017B7917-6B0A-4E9C-8757-F142E7B3C615",
"D292ECB1-F007-4CE7-A65C-4AB08AD689FD"
],
"dateCreated": "2011-08-29T20:34:41Z",
"dateModified": "2011-08-29T20:34:41Z",
"uuid": "5E680391-9BB0-4C8F-BC52-39F1836A717F",
}
],
"smartGroups": [
{
"title": "Markdown",
"predicate": "ANY parts.language.displayName ==[cd] \"Markdown\"",
"uuid": "41AD5A0A-84DE-4CD8-A951-7ED4060F7476",
},
],
"tags": [
{
"title": "lorem",
"uuid": "017B7917-6B0A-4E9C-8757-F142E7B3C615",
},
{
"title": "ipsum",
"uuid": "D292ECB1-F007-4CE7-A65C-4AB08AD689FD",
}
]
}
}