Skip to content

blobcache/hljson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hash-Linked JSON (HLJSON)

HLJSON is an extended JSON format that adds hash links as a first-class value type.

A hash link starts with @ and is followed by a base64-encoded 256-bit value using the Blobcache base64 alphabet (-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz).

In normal use, HLJSON behaves like JSON for standard JSON data. Object member names are still JSON strings, standard numbers and strings still parse the same way, and most existing semantic behavior remains familiar. The difference is that values like @2fQp... are valid at value positions.

Example HLJSON Object

{
  "createdAt": "2026-05-03T10:22:11Z",
  "authorInfo": @C6mP4w8eA0ovxVY8r1T2fM9bJ7QkL5sN3dH0uR2yX1z,
  "chunks": [
    {
      "cid": @aN8dW2qL9uF1xT6kV3rH0mP5sY7bC4eJ2gZ8nR1tD3f,
      "size": 262144
    },
    {
      "cid": @wQ4pM7kB1tY9dF3rN6uH2xV8sL0eJ5gC2aZ7nR1mT4q,
      "size": 183912
    }
  ],
}

The @... values are hash links (CIDs) and are HLJSON-specific value literals; unlike plain JSON strings, they are parsed as first-class link values.

Go Implementation

This repository is a fork of Go's encoding/json/v2 implementation with HLJSON support.

For Go integration, HLJSON exposes CID as an alias of blobcache.CID and treats it specially during encoding and decoding. Marshaling emits canonical full-length hash links. Unmarshaling accepts canonical links and also short forms, decoding what is present and leaving remaining CID bytes as zero.

This package is experimental application code, not a drop-in replacement for the standard library. Expect behavior to continue evolving around hash-link ergonomics as the format is exercised in real systems.

Additionally the Unmarshal function is now generic. It takes a T any type parameter. Unmarshal requires a pointer to any value, which can be enforced statically with this new API.

Blobcache Schema

HLJSON can be used as a Blobcache Schema. Blobcache will prohibit dangling references in Volumes using the HLJSON schema.

About

Hash-Linked JSON

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages