サンプル
github.com/json-iterator/go v1.1.11: jsoniter.ParseBytes
検証済みサンプル — golang github.com/json-iterator/go v1.1.11: jsoniter.ParseBytes. go 1.26 · linux debian/x64 · docker で contract を実行し、成功しました.
sha256:01ce8b117c1a390b46ac16ef2eee971f4aa3c7cd4abde248316ad58d744ac21d
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 go
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-05 |
ケース
HOW- ゴール
- verify jsoniter.ParseBytes in pkg:golang/github.com/json-iterator/go@v1.1.11
- シンボル
-
- jsoniter.ParseBytes
- 作成日
- 2026-09-05T01:47:46Z
コントラクト
- jsoniter.ParseBytes creates an Iterator from a byte slice and unmarshals into a struct
- jsoniter.ParseBytes streams sequential tokens from a byte slice using ReadArrayCB
- jsoniter.ParseBytes handles nested JSON objects via ReadObjectCB
- jsoniter.ParseBytes sets a non-nil Error on malformed JSON input
- jsoniter.ParseBytes allows reusing the iterator across different byte slices via ResetBytes
ファイル
- PROMPT.md
- csx.json
- go.mod
- go.sum
- main.go
- spec.json
- test/contract.go
ソース
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify jsoniter.ParseBytes in pkg:golang/github.com/json-iterator/go@v1.1.11
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/json-iterator/go@v1.1.11
Demonstrate these symbols/APIs:
- jsoniter.ParseBytes
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:f33d918be95d37c98f982f4c1c5eafdb07f81be6cf744b5d4d6fa07c3c182631","contract":["jsoniter.ParseBytes creates an Iterator from a byte slice and unmarshals into a struct","jsoniter.ParseBytes streams sequential tokens from a byte slice using ReadArrayCB","jsoniter.ParseBytes handles nested JSON objects via ReadObjectCB","jsoniter.ParseBytes sets a non-nil Error on malformed JSON input","jsoniter.ParseBytes allows reusing the iterator across different byte slices via ResetBytes"],"goal":"verify jsoniter.ParseBytes in pkg:golang/github.com/json-iterator/go@v1.1.11","kind":"HOW","packages":["pkg:golang/github.com/json-iterator/go@v1.1.11"],"schemaVersion":1,"symbols":["jsoniter.ParseBytes"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/json-iterator/go@v1.1.11"],"schemaVersion":1,"subject":"pkg:golang/github.com/json-iterator/go@v1.1.11","symbols":["jsoniter.ParseBytes"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/json-iterator/go v1.1.11
require (
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
)
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
package main
import (
"fmt"
jsoniter "github.com/json-iterator/go"
)
type ConfigRecord struct {
ServiceName string `json:"service_name"`
Port int `json:"port"`
Features []string `json:"features"`
}
func main() {
raw := []byte(`{"service_name":"auth-svc","port":8080,"features":["tls","metrics"]}`)
iter := jsoniter.ParseBytes(jsoniter.ConfigDefault, raw)
var record ConfigRecord
iter.ReadVal(&record)
if iter.Error != nil {
fmt.Printf("parse error: %v\n", iter.Error)
return
}
fmt.Printf("Parsed: service=%s port=%d features=%v\n", record.ServiceName, record.Port, record.Features)
}
{
"schemaVersion": 1,
"goal": "verify jsoniter.ParseBytes in pkg:golang/github.com/json-iterator/go@v1.1.11",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/json-iterator/go@v1.1.11"
],
"symbols": [
"jsoniter.ParseBytes"
]
}
package main
import (
"fmt"
"os"
"reflect"
jsoniter "github.com/json-iterator/go"
)
type testPayload struct {
Title string `json:"title"`
Score int `json:"score"`
Tags []string `json:"tags"`
}
func main() {
// Assertion 1: jsoniter.ParseBytes creates an Iterator from a byte slice and unmarshals into a struct
{
raw := []byte(`{"title":"alpha","score":95,"tags":["fast","compact"]}`)
iter := jsoniter.ParseBytes(jsoniter.ConfigDefault, raw)
var val testPayload
iter.ReadVal(&val)
if iter.Error != nil {
fmt.Fprintf(os.Stderr, "assertion 1 failed: unexpected error: %v\n", iter.Error)
os.Exit(1)
}
if val.Title != "alpha" || val.Score != 95 || !reflect.DeepEqual(val.Tags, []string{"fast", "compact"}) {
fmt.Fprintf(os.Stderr, "assertion 1 failed: parsed value mismatch: %+v\n", val)
os.Exit(1)
}
}
// Assertion 2: jsoniter.ParseBytes streams sequential tokens from a byte slice using ReadArrayCB
{
raw := []byte(`[10, 20, 30, 40]`)
iter := jsoniter.ParseBytes(jsoniter.ConfigDefault, raw)
var numbers []int
iter.ReadArrayCB(func(it *jsoniter.Iterator) bool {
numbers = append(numbers, it.ReadInt())
return true
})
if iter.Error != nil {
fmt.Fprintf(os.Stderr, "assertion 2 failed: array iteration error: %v\n", iter.Error)
os.Exit(1)
}
expected := []int{10, 20, 30, 40}
if !reflect.DeepEqual(numbers, expected) {
fmt.Fprintf(os.Stderr, "assertion 2 failed: expected %v, got %v\n", expected, numbers)
os.Exit(1)
}
}
// Assertion 3: jsoniter.ParseBytes handles nested JSON objects via ReadObjectCB
{
raw := []byte(`{"status":"ok","code":200}`)
iter := jsoniter.ParseBytes(jsoniter.ConfigDefault, raw)
fields := make(map[string]interface{})
iter.ReadObjectCB(func(it *jsoniter.Iterator, field string) bool {
switch field {
case "status":
fields["status"] = it.ReadString()
case "code":
fields["code"] = it.ReadInt()
default:
it.Skip()
}
return true
})
if iter.Error != nil {
fmt.Fprintf(os.Stderr, "assertion 3 failed: object callback error: %v\n", iter.Error)
os.Exit(1)
}
if fields["status"] != "ok" || fields["code"] != 200 {
fmt.Fprintf(os.Stderr, "assertion 3 failed: expected status 'ok' and code 200, got %+v\n", fields)
os.Exit(1)
}
}
// Assertion 4: jsoniter.ParseBytes sets a non-nil Error on malformed JSON input
{
raw := []byte(`{"unclosed": "string`)
iter := jsoniter.ParseBytes(jsoniter.ConfigDefault, raw)
var val map[string]interface{}
iter.ReadVal(&val)
if iter.Error == nil {
fmt.Fprintf(os.Stderr, "assertion 4 failed: expected error on malformed JSON, got nil\n")
os.Exit(1)
}
}
// Assertion 5: jsoniter.ParseBytes allows reusing the iterator across different byte slices via ResetBytes
{
firstBytes := []byte(`"hello"`)
iter := jsoniter.ParseBytes(jsoniter.ConfigDefault, firstBytes)
s1 := iter.ReadString()
if iter.Error != nil || s1 != "hello" {
fmt.Fprintf(os.Stderr, "assertion 5 failed: first read failed: %q, err: %v\n", s1, iter.Error)
os.Exit(1)
}
secondBytes := []byte(`"world"`)
iter.ResetBytes(secondBytes)
s2 := iter.ReadString()
if iter.Error != nil || s2 != "world" {
fmt.Fprintf(os.Stderr, "assertion 5 failed: second read failed after ResetBytes: %q, err: %v\n", s2, iter.Error)
os.Exit(1)
}
}
fmt.Println("All contract assertions passed successfully.")
}
オリジンシーダー
匿名