Console JSON formatter with query feature

Related tags

JSON jsonf
Overview

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
    }
Issues
  • 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

    opened by msabramo 1
  • 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:

    [[email protected] jsonf]$ pwd
    /Users/marca/go/src/github.com/miolini/jsonf
    
    [[email protected] 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
    
    opened by msabramo 1
Owner
Artem Andreenko
Software Engineer
Artem Andreenko
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

Qian Chen 182 Apr 27, 2022
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

Saddam H 1.9k Jun 22, 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.

Blues Inc 25 May 27, 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

M. J. Fromberger 2 Nov 26, 2021
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

Velmie 1 Dec 21, 2021
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

Josh Baker 10.5k Jun 20, 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

William Poussier 172 Jun 23, 2022
Fast JSON encoder/decoder compatible with encoding/json for Go

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

Masaaki Goshima 1.6k Jun 26, 2022
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

High Performance, Kubernetes Native Object Storage 3 May 10, 2022
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

Samit Ghimire 5 Mar 3, 2022
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

null 2 May 20, 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

Stepan Pyzhov 119 Jun 24, 2022
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

Aliaksandr Valialkin 1.6k Jun 21, 2022
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 $

skanehira 108 Apr 27, 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

Nick Law 47 May 18, 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

Aditya Mukerjee 2.5k Jun 23, 2022
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

Guillaume de Sagazan 86 May 31, 2022
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

William Poussier 128 Jun 1, 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

Maciek ZajÄ…c 100 May 10, 2022