Code Monkey home page Code Monkey logo

jsonpath's Introduction

Build Status Goreport License MIT

jsonpath - Json generation by dot notation

This library is very close to mongodb's dot notation with a bit of extensions.

Supported syntaxes

Standard dot notation

input hash value output json result
{"0.value":"100"} [{"value":"100"}]
{"1.value":"100"} [null, {"value":"100"}]
{"value":"100"} {"value":"100"}
{"value.1":"100"} {"value":[null, "100"]}
{"v.0.k":"100"} {"v":[{"k":100}]}

Extended

input hash value output json result
{"v.num()":"1.0"} {"v":1.0}
{"v.bool()":"true"} {"v":true}

Benchmarks

Run benchmarks

go test -bench=.

Results

v0.0.3

BenchmarkComplexJSONPathArray-8             	  100000	     12480 ns/op
BenchmarkSimpleJSONPathArrayWithNum-8       	  500000	      2654 ns/op
BenchmarkSimpleJSONPathArrayWithBool-8      	 1000000	      2319 ns/op
BenchmarkSimpleJSONPathArrayInsideArray-8   	  500000	      3066 ns/op
BenchmarkSimpleJSONPathArrays-8             	  500000	      2636 ns/op
BenchmarkSimpleJSONPathSimple-8             	 1000000	      1626 ns/op
BenchmarkJSONNative-8                       	 2000000	       959 ns/op

Installation

go get github.com/cthulhu/jsonpath

Usage

in := map[string]string{"0.value": "100.00"}
jsobBytes := jsonpath.Marshal(in)

For more examples check jsonpath_test.go file

LICENSE

See LICENSE file

jsonpath's People

Contributors

cthulhu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.