jsonpreprocess

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2019 License: MIT Imports: 8 Imported by: 1

README

jsonpreprocess

json preprocessor library and tools written in Go.

According to JSON, you cannot have comments in JSON. However sometimes you would like to have comments in documents.

This preprocessor can do:

  • trim comments
  • minify (trim comments and whitespaces).

This preprocessor accepts two style of comments.

  • line comment: from // to the end of line. example: // this is a comment
  • block comment: from /* to */. block comments cannot be nested. example: /* this is a comment */

example input

/* response example */
{
  "error": false, // true: if error occurred, false: otherwise
  "count": 23, // item total count
  "items": [ // items in this page
    {
      "id": 1,
      "name": "John Doe" // user name
    },
    {
      "id": 2,
      "name": "Paul Smith"
    }
  ]
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Minify

func Minify(input string) (string, error)

func TrimComment

func TrimComment(input string) (string, error)

func WriteCommentTrimmedTo

func WriteCommentTrimmedTo(writer io.Writer, input io.Reader) error

func WriteMinifiedTo

func WriteMinifiedTo(writer io.Writer, reader io.Reader) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL