0.1.0 • Published 4 years ago

jsonc-metadata v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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" 
            }
        }
    */
0.1.0

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago