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

Related tags

JSON json_spanner
Overview

JSON SPANNER

JSON Spanner is a Go package that provides a fast and simple way to filter or transform a json document. You can filter or transform json using SQL-like statements.

Getting Started

Installing

To start using JSON Spanner, install Go and run go get:

$ go get -u github.com/fuhongbo/json_spanner

This will retrieve the library.

Filter a json document

Use SQL-like statements to filter JSON, return true if conditions are met, and return false if not.

package main

import (
	"fmt"
	"github.com/fuhongbo/json_spanner"
)

func main() {
	eng, _ := NewFilter("test.a.b=1 and (b=2 or c=4)")
	result := eng.Valid(`{"test":{"a":{"b":1}},"b":3,"c":4}`)
	fmt.Println(result)
}

This will print:

true

Transform a json document

Use SQL-like statements to transform JSON.

package main

import "fmt"

func main() {
	eng, err := NewQuery("select test.a as x.t, 6.8 as x.d,b as x.b,c where test.a=1 and (b=2 or c=4)")
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	match, jsonStr, err := eng.Transform(`{"test":{"a":1},"b":3,"c":4}`)
    
	if !match{
		fmt.Println("the json document do not match the condition")
		return
    } 
	
	if err!=nil{
		fmt.Println(err.Error())
		return
    }
	fmt.Println(jsonStr)
}

This will print:

{
    "c": 4,
    "x": {
        "b": 3,
        "d": 6.8,
        "t": 1
    }
}

Currently supported conditional expressions

Expressions Remark
=
<>
>
>=
<
<=
AND
OR
=~ This special use to MQTT topic match
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
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
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
Kazaam was created with the goal of supporting easy and fast transformations of JSON data with Golang

kazaam Description Kazaam was created with the goal of supporting easy and fast transformations of JSON data with Golang. This functionality provides

Qntfy 205 Sep 17, 2021
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
Fast JSON serializer for golang.

easyjson Package easyjson provides a fast and easy way to marshal/unmarshal Go structs to/from JSON without the use of reflection. In performance test

Free and open source software developed at Mail.Ru 3.8k Jun 22, 2022
Fast Color JSON Marshaller + Pretty Printer for Golang

ColorJSON: The Fast Color JSON Marshaller for Go What is this? This package is based heavily on hokaccha/go-prettyjson but has some noticible differen

Tyler Brock 110 Jun 16, 2022
A fast json parser for go

rjson rjson is a json parser that relies on Ragel-generated state machines for most parsing. rjson's api is minimal and focussed on efficient parsing.

WillAbides 47 Jun 15, 2022
A blazingly fast JSON serializing & deserializing library

Sonic A blazingly fast JSON serializing & deserializing library, accelerated by JIT(just-in-time compiling) and SIMD(single-instruction-multi-data). B

Bytedance Inc. 3k Jun 24, 2022
Fast json for go. Lightweight fork of jsoniter.

jx Fast json for go. Lightweight fork of jsoniter. Features Reduced scope (no reflection or encoding/json adapter) Fuzzing, improved test coverage Dra

ogen 61 Jun 25, 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
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
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
a Go package to interact with arbitrary JSON

go-simplejson a Go package to interact with arbitrary JSON Importing import github.com/bitly/go-simplejson Documentation Visit the docs on Go package

Bitly 3.6k Jun 24, 2022
jsonc is a Go package that converts the jsonc format to standard json.

jsonc jsonc is a Go package that converts the jsonc format to standard json. The jsonc format is like standard json but allows for comments and traili

Josh Baker 60 May 20, 2022
A very rudimentary JSON compare package in GO

simple_json_compare A very rudimentary JSON compare package Sample code package main import ( "fmt" "github.com/CalypsoSys/simple_json_compare" )

Joe 0 Oct 20, 2021
A Go package to interact with arbitrary JSON

go-simplejson a Go package to interact with arbitrary JSON Importing import github.com/bitly/go-simplejson Documentation Visit the docs on Go package

LYF 0 Oct 20, 2021
This is an experimental package for working with JSON-LD documents in Go

JSON-LD ?? Simple JSON-LD in Go This is an experimental package for working with JSON-LD documents in Go. Experimental, Pre-Alpha Quality Please do no

null 3 Feb 22, 2022