The JSON data source in Polypheny allows querying JSON files as collections of documents in the document model. It supports both uploading and linking of JSON files. The adapter deduces data types automatically from the JSON content and operates in read-only mode, meaning it does not support DML queries. Background updates to the file are permitted and reflected by this source.
Adapter Configuration
The JSON adapter requires the following settings:
- directory: Specifies the directory containing the JSON files. Either a single file or a directory of JSON files can be specified.
Data Type Deductions
The JSON adapter automatically deduces data types to be used in Polypheny based on the JSON content. The following mapping is used:
JSON Type | Polypheny Type (PolyType) |
---|---|
NULL | NULL |
ARRAY | LIST |
OBJECT | MAP |
NUMBER | NUMBER |
STRING | STRING |
BOOLEAN | BOOLEAN |
Example JSON File
Below is an example of a JSON file supported by the JSON source. In this scenario, the fields id
and rating
will internally be represented as a PolyNumber
. The fields title
, author
, and published_date
will be represented as PolyStrings
. Lastly, the field is_featured
will be a boolean
.
[
{
"id": 1,
"title": "Unlocking the Secrets of Deep Space",
"author": "Samantha Ray",
"published_date": "2024-04-24",
"is_featured": true,
"rating": 4.7
},
{
"id": 2,
"title": "Revolutionizing Agriculture with AI",
"author": "Marcus O'Neill",
"published_date": "2024-04-10",
"is_featured": false,
"rating": 4.2
}
]
Deployment
The adapter can be deployed via Polypheny-UI (Adapters -> Sources). The adapter operates in two modes:
- Uploading: The file is uploaded to Polypheny; changes to the file are not reflected in Polypheny.
- Linking: Polypheny accesses the file at a specified location; changes to the file are immediately visible. The file must reside on the same host as Polypheny, and Polypheny must have access rights. The file name should not include spaces.
Upon deployment, JSON files are mapped as collections of documents in a new namespace named after the source name. A source named json1
will thus create a corresponding namespace also called json1
. The source name can be set upon deployment.