Console JSON formatter with query feature

Console JSON formatter with query feature.

Install:

$ go get github.com/miolini/jsonf

Usage:

Usage of jsonf:
  -c=true: colorize output
  -d=false: debug output to stderr
  -f=true: format output json to stdout
  -q="": json query
  -s=true: syntax hightlight
  -v=false: verbose output to stderr

Examples:

$ echo '{"uid":1,"email":"[email protected]","address":{"city":"New-York","country":"US"}}' | jsonf

Output

$ echo '{"uid":1,"email":"[email protected]","address":{"city":"New-York","country":"US"}}' \
  | jsonf -q 'value["address"]["country"]'
"US"

Using from another Golang program

import (
  ...
  "github.com/miolini/jsonf/jsonflib"
  ...
)
...
    jsonRaw, err := jsonflib.Highlight(
      jsonRaw,
      jsonflib.HighlightFlags{Colorize: true, Verbose: false, Debug: false},
    )
    if err != nil {
      return err
    }
Owner
Artem Andreenko
Software Engineer
Artem Andreenko
Similar Resources

JSON Spanner - A Go package that provides a fast and simple way to filter or transform a json document

JSON SPANNER JSON Spanner is a Go package that provides a fast and simple way to

Sep 14, 2022

Abstract JSON for golang with JSONPath support

Abstract JSON Abstract JSON is a small golang package provides a parser for JSON with support of JSONPath, in case when you are not sure in its struct

Jan 5, 2023

Fast JSON parser and validator for Go. No custom structs, no code generation, no reflection

fastjson - fast JSON parser and validator for Go Features Fast. As usual, up to 15x faster than the standard encoding/json. See benchmarks. Parses arb

Jan 5, 2023

Small utility to create JSON objects

Small utility to create JSON objects

gjo Small utility to create JSON objects. This was inspired by jpmens/jo. Support OS Mac Linux Windows Requirements Go 1.1.14~ Git Installtion Build $

Dec 8, 2022

A Go package for handling common HTTP JSON responses.

go-respond A Go package for handling common HTTP JSON responses. Installation go get github.com/nicklaw5/go-respond Usage The goal of go-respond is to

Sep 26, 2022

Automatically generate Go (golang) struct definitions from example JSON

gojson gojson generates go struct definitions from json or yaml documents. Example $ curl -s https://api.github.com/repos/chimeracoder/gojson | gojson

Jan 1, 2023

A JSON diff utility

JayDiff A JSON diff utility. Install Downloading the compiled binary Download the latest version of the binary: releases extract the archive and place

Dec 11, 2022

Fast and flexible JSON encoder for Go

Fast and flexible JSON encoder for Go

Jettison Jettison is a fast and flexible JSON encoder for the Go programming language, inspired by bet365/jingo, with a richer features set, aiming at

Dec 21, 2022

Create go type representation from json

json2go Package json2go provides utilities for creating go type representation from json inputs. Json2go can be used in various ways: CLI tool Web pag

Dec 26, 2022
Comments
  • Add .travis.yml suitable for Golang

    Add .travis.yml suitable for Golang

    to stop Travis CI from failing, because there's no .travis.yml, so it assumes that it's working with a Ruby program.

    Travis CI builds for previous PRs that have failed with errors (e.g.: https://travis-ci.org/miolini/jsonf/builds/131450328#L6-L136), but the Travis CI build for this PR passes: https://travis-ci.org/miolini/jsonf/builds/131451987

  • Move functions into new jsonflib package

    Move functions into new jsonflib package

    Extract the useful Query and Highlight functions into a new jsonflib package, so that other Golang programs can import github.com/miolini/jsonf/jsonflib and use these functions.

    Example usage:

    import (
      ...
      "github.com/miolini/jsonf/jsonflib"
      ...
    )
    ...
        jsonRaw, err := jsonflib.Highlight(
          jsonRaw,
          jsonflib.HighlightFlags{Colorize: true, Verbose: false, Debug: false},
        )
        if err != nil {
          return err
        }
    

    I also added the above example to the README.md at https://github.com/msabramo/jsonf/blob/library/README.md#using-from-another-golang-program

    I also added a test for jsonflib.Highlight in 65feb80 and I added the .travis.yml change from https://github.com/miolini/jsonf/pull/3 in 7831a38, so that I could see the test I added passing in Travis CI and get a nice, warm, fuzzy feeling (and it is passing indeed -- see https://travis-ci.org/miolini/jsonf/jobs/131466384#L176-L181).

    Example of running the tests from the command line:

    [marca@marca-mac2 jsonf]$ pwd
    /Users/marca/go/src/github.com/miolini/jsonf
    
    [marca@marca-mac2 jsonf]$ go test -v ./...
    ?       github.com/miolini/jsonf    [no test files]
    === RUN   TestSimple
    --- PASS: TestSimple (0.00s)
    PASS
    ok      github.com/miolini/jsonf/jsonflib   0.013s
    
Related tags
JSON query in Golang

gojq JSON query in Golang. Install go get -u github.com/elgs/gojq This library serves three purposes: makes parsing JSON configuration file much easie

Dec 28, 2022
A simple Go package to Query over JSON/YAML/XML/CSV Data
A simple Go package to Query over JSON/YAML/XML/CSV Data

A simple Go package to Query over JSON Data. It provides simple, elegant and fast ODM like API to access, query JSON document Installation Install the

Dec 27, 2022
JSONata in Go Package jsonata is a query and transformation language for JSON

JSONata in Go Package jsonata is a query and transformation language for JSON. It's a Go port of the JavaScript library JSONata.

Nov 8, 2022
A library to query the godoc.org JSON API.

gopkg This repository provides minimal Go package that makes queries against the godoc.org JSON API. Since that site has mostly been subsumed by pkg.g

Dec 2, 2022
JSON:API compatible query string parser

QParser The package helps to parse part of the URL path and its parameters string to a handy structure. The structure format is compatible with the JS

Dec 21, 2021
Get JSON values quickly - JSON parser for Go
Get JSON values quickly - JSON parser for Go

get json values quickly GJSON is a Go package that provides a fast and simple way to get values from a json document. It has features such as one line

Dec 28, 2022
JSON diff library for Go based on RFC6902 (JSON Patch)

jsondiff jsondiff is a Go package for computing the diff between two JSON documents as a series of RFC6902 (JSON Patch) operations, which is particula

Dec 4, 2022
Fast JSON encoder/decoder compatible with encoding/json for Go
Fast JSON encoder/decoder compatible with encoding/json for Go

Fast JSON encoder/decoder compatible with encoding/json for Go

Jan 6, 2023
Package json implements encoding and decoding of JSON as defined in RFC 7159

Package json implements encoding and decoding of JSON as defined in RFC 7159. The mapping between JSON and Go values is described in the documentation for the Marshal and Unmarshal functions

Jun 26, 2022
Json-go - CLI to convert JSON to go and vice versa
Json-go - CLI to convert JSON to go and vice versa

Json To Go Struct CLI Install Go version 1.17 go install github.com/samit22/js

Jul 29, 2022