Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
69fa32e
*: add go.mod and go.sum
AnnaShaleva Sep 15, 2021
593850d
README: add note about fork motivations
AnnaShaleva Sep 15, 2021
fed94d8
github: add Tests github workflow
AnnaShaleva Sep 15, 2021
aceee4d
Merge pull request #2 from AnnaShaleva/update-readme
roman-khimov Sep 15, 2021
a668059
encode: escape non-ascii characters during encoding
AnnaShaleva Sep 15, 2021
e1b6cce
Merge pull request #1 from AnnaShaleva/fix-unescaping
roman-khimov Sep 15, 2021
45541ed
tables: escape apostrophe as well for C# compatibility
roman-khimov Jan 10, 2022
25110be
Merge pull request #4 from nspcc-dev/escape-apostrophe
roman-khimov Jan 11, 2022
b9bf885
*: escape HTML chars into uppercase unicode bytes
AnnaShaleva Nov 23, 2023
4e51dba
Merge pull request #7 from nspcc-dev/uppercase-unicode
roman-khimov Nov 23, 2023
cb54cb3
.github: drop Linter job
AnnaShaleva Nov 23, 2023
c13c5ca
.github: upgrade Go for testing workflows
AnnaShaleva Nov 23, 2023
3374ff1
Merge pull request #8 from nspcc-dev/drop-linter
roman-khimov Nov 23, 2023
6f8327a
tables: escape double quotes for C# compatibility
AliceInHunterland Jan 10, 2024
296698a
Merge pull request #9 from nspcc-dev/quotes
AnnaShaleva Jan 12, 2024
a6f15fe
encode: make it compatible with .NET, fix #3
roman-khimov Feb 29, 2024
d401367
*: go fmt
roman-khimov Feb 29, 2024
bbb02e8
README: make it a bit more useful
roman-khimov Feb 29, 2024
a2ece04
workflows: update OS/action versions
roman-khimov Feb 29, 2024
fdcc534
Merge pull request #11 from nspcc-dev/fix-dotnet-compat
AnnaShaleva Feb 29, 2024
13d6bbe
*: goimports
roman-khimov Feb 29, 2024
a7eb203
workflows: use newer Go
roman-khimov Feb 29, 2024
f2fd72d
workflows: test on windows and amd64/arm64 macs
roman-khimov Feb 29, 2024
811dd20
go.mod: use Go 1.20 min, fix #5
roman-khimov Feb 29, 2024
bcb1c4b
encode: use built-in sync.Map type
roman-khimov Feb 29, 2024
3da2262
example: simplify dependencies
roman-khimov Feb 29, 2024
2d9e480
tests: stop using deprecated (since Go 1.16) io/ioutil
roman-khimov Feb 29, 2024
1952640
*: use errors.Is for error checks
roman-khimov Feb 29, 2024
58d6d50
*: interface{} -> any
roman-khimov Feb 29, 2024
551baa5
encode: check Write error
roman-khimov Feb 29, 2024
1205ed9
*: fix godot warnings
roman-khimov Feb 29, 2024
19c018b
fold: fix whitespace error
roman-khimov Feb 29, 2024
7ff1a68
fold: simplify code
roman-khimov Feb 29, 2024
a4ef347
encode: don't initialize count
roman-khimov Feb 29, 2024
c406b37
*: fix exhaustive linter warnings
roman-khimov Feb 29, 2024
c0749cf
workflows: drop wrong coverage package limitations
roman-khimov Feb 29, 2024
d0a949c
workflows: add lint/codeql
roman-khimov Feb 29, 2024
04b64f9
decode_test: fix unused linter warnings
roman-khimov Feb 29, 2024
7cf27c7
decode_test: go fmt
roman-khimov Feb 29, 2024
752aa20
*: fix errcheck warnings
roman-khimov Feb 29, 2024
ef71ecc
*: suppress staticcheck/govet linters where we intentionally have bad…
roman-khimov Feb 29, 2024
0246b01
Merge pull request #12 from nspcc-dev/up-go
AnnaShaleva Mar 1, 2024
f509a2b
golangci: add linter config (taken from NeoGo)
roman-khimov Aug 9, 2024
ed98fd4
go.mod: upgrade to Go 1.21 min
roman-khimov Aug 9, 2024
72c198a
*: fix godot warnings
roman-khimov Aug 9, 2024
512a921
encode: use slices.SortFunc where appropriate
roman-khimov Aug 9, 2024
7bc9255
decode: apply gofmt -s
roman-khimov Aug 9, 2024
3db0a70
*: fix whitespace errors reported by linter
roman-khimov Aug 9, 2024
3083330
stream: suppress revive linter errors
roman-khimov Aug 9, 2024
712357f
decode: drop redundant else branch
roman-khimov Aug 9, 2024
8ca7431
*: simplify var declarations
roman-khimov Aug 9, 2024
bb5ef01
example: simplify increment
roman-khimov Aug 9, 2024
9a37587
test: suppress errorlint in cases where it doesn't make sense
roman-khimov Aug 9, 2024
a3ffb79
*: fix errorlint warnings
roman-khimov Aug 9, 2024
dd94775
Merge pull request #13 from nspcc-dev/up-go
AnnaShaleva Aug 15, 2024
180b9a5
go.mod: upgrade to Go 1.22 min
roman-khimov Aug 28, 2024
af4b489
*: use Go 1.22+ ranging over integers
roman-khimov Aug 28, 2024
1cbefe4
scanner: switch test to math/rand/v2
roman-khimov Aug 28, 2024
2b0701a
golangci: don't use deprecated linter
roman-khimov Aug 28, 2024
6fb2953
*: use PointerTo instead of PtrTo
roman-khimov Aug 28, 2024
291b000
Merge pull request #15 from nspcc-dev/go-1.22
AnnaShaleva Aug 30, 2024
621e376
workflows: switch to org-wide linter
roman-khimov Sep 10, 2024
d2ad7ca
Merge pull request #16 from nspcc-dev/org-linter
AnnaShaleva Sep 10, 2024
e022290
workflows: drop macos-12 runner support
AnnaShaleva Nov 5, 2024
8138dd0
Merge pull request #17 from nspcc-dev/drop-macos-12
roman-khimov Nov 5, 2024
cff619b
workflows: use ubuntu-latest for testing
roman-khimov Feb 26, 2025
ae223c3
workflows: switch to CodeQL v3
roman-khimov Feb 26, 2025
23a4100
workflows: switch to Go 1.23/1.24 for testing
roman-khimov Feb 26, 2025
fb3f82b
Merge pull request #19 from nspcc-dev/go-1.23
AnnaShaleva Feb 26, 2025
c4cb39d
go.mod: upgrade to Go 1.24, fix #18
roman-khimov Sep 9, 2025
9bbd4eb
*: use Go 1.24 b.Loop() in benchmarks
roman-khimov Sep 9, 2025
9e1cb0b
tags: use strings.FieldsFuncSeq to simplify code
roman-khimov Sep 9, 2025
6fb4472
Merge pull request #21 from nspcc-dev/go-1.24
AnnaShaleva Sep 11, 2025
d3692c8
*: fix QF1012 lint issue
End-rey Sep 24, 2025
6424ffa
*: fix QF1008 lint issue
End-rey Sep 24, 2025
2d12ea8
Merge pull request #22 from nspcc-dev/fix-linter-errors
roman-khimov Sep 24, 2025
7dbfaaa
workflows: use the latest Windows version for tests
roman-khimov Dec 8, 2025
81cfd6f
workflows: use the latest MacOS runner for tests
roman-khimov Dec 8, 2025
f8941a1
Merge pull request #23 from nspcc-dev/runners
AnnaShaleva Dec 10, 2025
1d4423f
go.mod: upgrade to Go 1.25+, fix #20
roman-khimov Feb 20, 2026
d824a6e
*: use reflect.TypeAssert for more efficient casts
roman-khimov Feb 20, 2026
491b46e
*: ignore new staticcheck warnings for tests
roman-khimov Feb 20, 2026
e25dad7
Merge pull request #25 from nspcc-dev/go-1.25
AnnaShaleva Feb 20, 2026
afae2a6
*: apply `modernize` suggestions
AnnaShaleva Feb 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Tests

on:
pull_request:
branches:
- master
types: [opened, synchronize]
paths-ignore:
- '*.md'
workflow_dispatch:

env:
GO111MODULE: "on"

jobs:
test_cover:
name: Coverage
runs-on: ubuntu-latest

env:
CGO_ENABLED: 0
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.26

- name: Write coverage profile
run: go test -v ./... -coverprofile=./coverage.txt -covermode=atomic

- name: Upload coverage results to Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: false
path_to_write_report: ./coverage.txt
verbose: true

tests:
name: Go
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_versions: [ '1.25', '1.26' ]
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
# Only latest Go version for Windows and MacOS.
- os: windows-latest
go_versions: '1.25'
- os: macos-latest
go_versions: '1.25'
# Exclude latest Go version for Ubuntu as Coverage uses it.
- os: ubuntu-latest
go_versions: '1.26'
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '${{ matrix.go_versions }}'

- name: Run tests
run: go test -v -race ./...

lint:
name: Linter
uses: nspcc-dev/.github/.github/workflows/go-linter.yml@master

codeql:
name: CodeQL
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
go-ordered-json
===============
.NET-compatible JSON library
============================

There are some legacy/stupid applications[1] that you need to interoperate with,
and they for whatever reason require that the JSON you're using is ordered in
a particular way (contrary to the JSON specifications).
It's made for 100% compatibility with the JSON variation used by
[Neo blockchain](https://github.com/neo-project/). There are three problems
there:
* it's ordered (that's why it's a fork of [go-ordered-json](https://github.com/virtuald/go-ordered-json))
* it has different conventions regarding control and "special" symbols
* it has different conventions wrt incorrect UTF-8

Unfortunately, the golang authors are not willing to support such a broken use
case, so on [their advice](https://groups.google.com/forum/#!topic/golang-dev/zBQwhm3VfvU)
this is a fork of the golang encoding/json package, with the ordered JSON
support originating with a patch from
[Peter Waldschmidt](https://go-review.googlesource.com/c/7930/).
The primary user of this library is [NeoGo](https://github.com/nspcc-dev/neo-go/),
it has to be 100% compatible with C# implementation to correctly process
transactions, that's why we're maintaining this library and solving any
inconsistencies with .NET libraries if found.

**If you can, you should avoid using this package**. However, if you can't
avoid it, then you are welcome to. Provided under the MIT license, just like
golang.

Known broken applications
-------------------------

* [1][Windows Communication Foundation Json __type ordering](https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/stand-alone-json-serialization#type-hint-position-in-json-objects)
10 changes: 5 additions & 5 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ package json
import (
"bytes"
"compress/gzip"
"io/ioutil"
"io"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -47,7 +47,7 @@ func codeInit() {
if err != nil {
panic(err)
}
data, err := ioutil.ReadAll(gz)
data, err := io.ReadAll(gz)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -83,7 +83,7 @@ func BenchmarkCodeEncoder(b *testing.B) {
b.StartTimer()
}
b.RunParallel(func(pb *testing.PB) {
enc := NewEncoder(ioutil.Discard)
enc := NewEncoder(io.Discard)
for pb.Next() {
if err := enc.Encode(&codeStruct); err != nil {
b.Fatal("Encode:", err)
Expand Down Expand Up @@ -138,13 +138,13 @@ func BenchmarkDecoderStream(b *testing.B) {
var buf bytes.Buffer
dec := NewDecoder(&buf)
buf.WriteString(`"` + strings.Repeat("x", 1000000) + `"` + "\n\n\n")
var x interface{}
var x any
if err := dec.Decode(&x); err != nil {
b.Fatal("Decode:", err)
}
ones := strings.Repeat(" 1\n", 300000) + "\n\n\n"
b.StartTimer()
for i := 0; i < b.N; i++ {
for i := range b.N {
if i%300000 == 0 {
buf.WriteString(ones)
}
Expand Down
Loading