Repository navigation
jsonc/v0.1.4
First public release. The earlier jsonc/v0.1.1–jsonc/v0.1.3 tags were pre-releases; they are retracted in go.mod, and everything they contained is in this release.
Added
- Lossless JSONC parser (tolerant by default,
Strict()for plain JSON matchingencoding/json.Valid), comments attached to members,file:line:colerrors. - Read:
JSON,Decode,Getand typed getters,Has,Keys,Len,Kind,Comment,Pos,KeyPos, dotted paths and JSON Pointer;Readone-call. - Edit:
Set,SetAfter,SetBefore,Delete,Append,Insert,Remove,SetComment,RemoveComment,Disable,Restore,Merge,Clone;Save/SaveAsthroughatomicfilewith save guards. - Dynamic values: expansion through the base engine with Lookupers, Resolvers, CommandRunner and ValueTransformers (off by default; positioned errors);
$extendsthroughExtendedwhen an Includer is installed. Lint, and packagesformat(Format,Minify),generate(builders,FromStruct),schema(FromStruct,Parse/Load,Validate,Plugin),diff(Diff).- Tests: JSONTestSuite conformance, a JSONC case set, property tests through
texttest, fuzz targets for parse, edits, merge, format, lint, extends, schema and diff.
Changed during the pre-releases
schema.Pluginis now also aplugin.SaveGuard: installing it makesSaveandSaveAsrefuse a document with schema errors, leaving the file untouched. Warnings never refuse a save. It used to be aValidatoronly, soSavenever ran it.- A failing or refused
$(command)is now an error fromGetExpanded,ExpandedandReadwith expansion, carrying the value'sfile:line:coland unwrapping to*expand.CommandError; it used to expand to""silently. Readon a missing file now returns an error that names the path and wrapsfs.ErrNotExist, matchingdotenv.Read; it used to return an empty map and no error.Openis unchanged: a missing file is still an empty document thatSavecreates.
Fixed during the pre-releases
Doc.Pos,Doc.KeyPosand every error position raced when several goroutines read one uneditedDoc: the lazily built offset index is now an atomic pointer, reset the same way by every edit.Clonebuilds a newDocinstead of copying one. Pinned by a race-detector test.schema.Parsereported atypethat is neither a string nor an array asmust be an array of strings; a single type name is valid too, so it now saysmust be a string or an array of strings.