← All procedures

fs.read.json

Read and parse JSON file

CLI
Package
@procedures/fs · README
Path
["fs","read.json"]
CLI
mark fs read.json --path <string>
As data
{"$proc":["fs","read.json"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/fs"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["fs","read.json"], { path: "<path>" });
console.log(JSON.stringify(result));

From the command line

$ mark fs read.json --path <string>

As data, in a program

{ "$proc": ["fs", "read.json"], "input": { "path": "<path>" } }

Input

FieldTypeRequiredDefaultDescription
pathstringyesPath to JSON file

Output

FieldTypeRequiredDefaultDescription
pathstringyesThe path of the file
dataanyyesThe parsed JSON value
statsobjectyesThe stats of the file
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "Path to JSON file"
      }
    },
    "required": [
      "path"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The path of the file"
      },
      "data": {
        "description": "The parsed JSON value"
      },
      "stats": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "description": "The path"
          },
          "type": {
            "type": "string",
            "enum": [
              "file",
              "directory",
              "other"
            ],
            "description": "file, directory or other"
          },
          "size": {
            "type": "number",
            "description": "The size, in bytes"
          },
          "mtime": {
            "type": "string",
            "description": "The time of the last change (ISO 8601)"
          },
          "ctime": {
            "type": "string",
            "description": "The time of the last status change (ISO 8601)"
          },
          "atime": {
            "type": "string",
            "description": "The time of the last access (ISO 8601)"
          },
          "mode": {
            "type": "number",
            "description": "The mode bits (type and permissions)"
          }
        },
        "required": [
          "path",
          "type",
          "size",
          "mtime",
          "ctime",
          "atime",
          "mode"
        ],
        "additionalProperties": {},
        "description": "The stats of the file"
      }
    },
    "required": [
      "path",
      "data",
      "stats"
    ],
    "additionalProperties": {}
  }
}