JSPM

jsonc-metadata

0.0.5
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q29225F
  • License MIT

Extract field metadata from comments in JSONC files.

Package Exports

  • jsonc-metadata

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jsonc-metadata) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSONC-METADATA

Extract field metadata from comments in JSONC files.

JSONC is JSON with comments. This library helps in extracting metadata for each field from comments.

Depends on jsonc-parser library from microsoft for parsing jsonc.

Usage

import { parse, yamlCommentParser }  from "jsonc-metadata";


const jsonc = `{
        // this is the name
        "name": "JSONC",

        // this is tags
        "tags" : [
            "library",
            "node",
            "comments"
        ],
    }`;

    const metadata = parse(jsonc); 
    /*
        {
            "name": ["this is the name"],
            "tags": ["this is tags"]
        }
    */


    const jsoncWithYamlComments = `{
        // message: this is name field
        "name": "JSONC",

        // message: these are tags
        "tags" : [
            "library",
            "node",
            "comments"
        ],
    }`;

    const metadata2 = parse(jsonc, yamlCommentParser); 
    
    /* 
        { 
            "name": {
                "message": "this is the name"
            }, 
            "tags": {
                "message" : "these are tags" 
            }
        }
    */