• Stars
    star
    82
  • Rank 382,843 (Top 8 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 2 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

High performance JSON iterator & validator for Go
GoDoc GoReportCard Coverage Status

jscan

jscan provides high-performance zero-allocation JSON iterator and validator for Go. This module doesn't provide Marshal/Unmarshal capabilities yet, instead it focuses on highly efficient iteration over JSON data with on-the-fly validation.

An experimental decoder with backward compatibility to encoding/json is WiP πŸ§ͺ and is expected to be introduced together with jscan v3.

jscan is tested against https://github.com/nst/JSONTestSuite, a comprehensive test suite for RFC 8259 compliant JSON parsers.

See jscan-benchmark for benchmark results 🏎️ 🏁.

Example

https://go.dev/play/p/moP3l9EkebF

package main

import (
	"fmt"

	"github.com/romshark/jscan/v2"
)

func main() {
	j := `{
		"s": "value",
		"t": true,
		"f": false,
		"0": null,
		"n": -9.123e3,
		"o0": {},
		"a0": [],
		"o": {
			"k": "\"v\"",
			"a": [
				true,
				null,
				"item",
				-67.02e9,
				["foo"]
			]
		},
		"a3": [
			0,
			{
				"a3.a3":8
			}
		]
	}`

	err := jscan.Scan(j, func(i *jscan.Iterator[string]) (err bool) {
		fmt.Printf("%q:\n", i.Pointer())
		fmt.Printf("β”œβ”€ valueType:  %s\n", i.ValueType().String())
		if k := i.Key(); k != "" {
			fmt.Printf("β”œβ”€ key:        %q\n", k[1:len(k)-1])
		}
		if ai := i.ArrayIndex(); ai != -1 {
			fmt.Printf("β”œβ”€ arrayIndex: %d\n", ai)
		}
		if v := i.Value(); v != "" {
			fmt.Printf("β”œβ”€ value:      %q\n", v)
		}
		fmt.Printf("└─ level:      %d\n", i.Level())
		return false // Resume scanning
	})

	if err.IsErr() {
		fmt.Printf("ERR: %s\n", err)
		return
	}
}

More Repositories

1

webwire-go

A transport independent asynchronous duplex messaging library for Go
Go
216
star
2

Go-1-2-Proposal---Immutability

A a Go 1/2 language feature proposal to immutability
171
star
3

dgraph_graphql_go

A GraphQL + Dgraph + Go + HTTP based backend service demo.
Go
50
star
4

QuickStreams

An asynchronous programming library for the QML programming language (Proof of Concept)
C++
46
star
5

llparser

A universal LL top-down parser written in Go
Go
45
star
6

sched

A job scheduler for Go with the ability to fast-forward time.
Go
27
star
7

goesgen

Go code generator for event-sourced systems
Go
12
star
8

webwire-js

A client implementation for the webwire-go asynchronous messaging library.
JavaScript
12
star
9

watchserve

An HTTP file server that's watching the served file for updates and automatically reloads the page
Go
9
star
10

taskhub

A GraphQL demo of a JIRA-like task tracking system demonstrating the use of persisted queries.
Go
7
star
11

eventlog

A persistent append-only event database
Go
7
star
12

go-battle-simulator

A concurrent battle simulator written in Go (#codingforfun)
Go
5
star
13

tmdwg-go

A timed analogue of sync.WaitGroup for Golang
Go
5
star
14

qbeon.com

The website that is hosted on qbeon.com serving as an introduction of Qbeon and the Qube network attache storage device with the intention to attract investment.
HTML
5
star
15

utf8

A fork of the encoding/utf8 Go standard library package with experimental performance optimizations.
Go
4
star
16

gapi

Graph API
Go
3
star
17

valfile

A CLI tool to statically check env vars, YAML, TOML, JSON, HCL, Jsonnet and .env files against a Go type.
Go
3
star
18

eventlog-example

This example showcases an event-sourced CQRS system based on github.com/romshark/eventlog
Go
3
star
19

jscan-experimental-decoder

This is an experimental JSON decoder for Go based on jscan
Go
2
star
20

rebuzzer

Rebuzzer is a fullscreen button in the browser which executes a command on the server by clicking on it
JavaScript
2
star
21

pres-jscan

Presentation of jscan at Go meetup in Zurich (October 3th 2023)
Go
2
star
22

shallyapassbot

Telegram anti-spam bot
Go
1
star
23

messenger-sim

A simulation of an event-sourced messenger system in Go
Go
1
star
24

contacts.qbeon.com

VCards for public appearance
HTML
1
star
25

jsonvalidate-go

High-performance JSON validation in Go
Go
1
star
26

jscan-benchmark

Benchmarks comparing github.com/romshark/jscan to other modules
Go
1
star
27

webwire-example-postboard

An advanced full-featured example of a webwire-go powered real-time application
Go
1
star
28

service-modelling-language

An experimental specification of an abstract service modelling language similar to GraphQL
Standard ML
1
star