Skip to content

A simple JSON parser written in Typescript. Takes a JSON string and convert it into an AST

License

Notifications You must be signed in to change notification settings

PeterKwesiAnsah/json-parser

Repository files navigation

JSON Validator and AST Parser

A powerful TypeScript-based JSON parser that not only validates JSON strings according to the JSON specification but also transforms them into a structured Abstract Syntax Tree (AST) format. Handles edge cases like nested objects and arrays.

SETUP

Run to install dev dependencies:

npm install

Now to run the main script:

npm run parse

USAGE

JSONParser(`{"key": "value", "array": [1, 2, 3]}`)

//Output
{
  "type": "JSON",
  "properties": [
    {
      "key": "key",
      "value": "value"
    },
    {
      "key": "array",
      "value": {
        "type": "JSONArray",
        "elements": [
          1,
          2,
          3
        ]
      }
    }
  ]
}

TESTS

npm run test

About

A simple JSON parser written in Typescript. Takes a JSON string and convert it into an AST

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published