JSONC is JSON with JavaScript style comments. This provides a scanner and fault-tolerant parser that can process
JSONC but is also useful for standard JSON.
In particular for just parsing like JSON.parse use the parse function. All the other functions provided involve
AST manipulation:
- the`parse`functionevaluatestheJavaScriptobjectrepresentedbyJSONstringinafault-tolerantfashion. - the `scanner` tokenizestheinputstringintotokensandtokenoffsets - the `visit` functionimplementsa 'SAX' styleparserwithcallbacksfortheencounteredpropertiesandvalues. - the `parseTree` functioncomputesahierarchicalDOMwithoffsetsrepresentingtheencounteredpropertiesand values. - the `getLocation` APIreturnsalocationobjectthatdescribesthepropertyorvaluelocatedatagivenoffsetin aJSONdocument. - the `findNodeAtLocation` APIfindsthenodeatagivenlocationpathinaJSONDOM. - the `format` APIcomputeseditstoformataJSONdocument. - the `modify` APIcomputeseditstoinsert, removeorreplaceapropertyorvalueinaJSONdocument. - the `applyEdits` APIapplieseditstoadocument.
JSONCis JSON with JavaScript style comments. This provides a scanner and fault-tolerant parser that can processJSONCbut is also useful for standard JSON.In particular for just parsing like
JSON.parseuse theparsefunction. All the other functions provided involve AST manipulation:See
https://www.npmjs.com/package/jsonc-parser