Open a JSON

Opens a JSON file from either an S3 URL or an uploaded file.

Overview

This procedure opens and reads a JSON file from either a specified S3 URL or uploaded directly to Kognitos. It retrieves the file content, parses it as JSON, and returns the JSON object.

Input

Concept
Type
Description
Required
Default

file

string

The S3 URL of the JSON file to be opened

Yes

N/A

Output

Concept
Description

json

The JSON object obtained from the file

Examples

1. Opening a JSON file from S3

This example opens a JSON file stored at the specified S3 URL and returns the parsed JSON object.

the file is "s3://my-bucket/data/json.json"
open a json at the string

2. Opening a JSON file from an uploaded file

This example opens a JSON file that was uploaded by the user to Kognitos.

the file
open the json at the file

3. Reading a JSON file from S3

This example reads a JSON file stored at the specified S3 URL and returns the parsed JSON object. This is an alternative syntax to "open a json at a file" and provides the same functionality.

the file is "s3://my-bucket/data/json.json"
read the json from the file

4. Reading a JSON file from an uploaded resource

This example demonstrates reading a JSON file containing student and course information from a test resource. The result would be a JSON object with nested structures for student details and course arrays.

the file is "s3://bucket-name/resources/example.json"
read the json from the file

5. Error handling for invalid JSON files

This example shows the error handling when attempting to read an invalid or non-existent JSON file. The system will prompt with "Could not read a json from a file."

the invalid file is "some-file"
read the json from the invalid file

Last updated

Was this helpful?