Skip to content
theoryPublic

About

PostgreSQL-compatible SQL-standard SQL/JSON in Go

Topics

Resources

Stars

12 stars

Watchers

1 watching

Forks

Repository files navigation

Go SQL/JSON

License GoDoc Build Status Code Coverage

The SQL/JSON package provides PostgreSQL-compatible SQL-standard SQL/JSON functionality in Go. For now that means jsonpath. An example:

func main() {
    src := []byte(`{
      "track": {
        "segments": [
          {
            "location":   [ 47.763, 13.4034 ],
            "start time": "2018-10-14 10:05:14",
            "HR": 73
          },
          {
            "location":   [ 47.706, 13.2635 ],
            "start time": "2018-10-14 10:39:21",
            "HR": 135
          }
        ]
      }
    }`)

    // Parse the JSON.
    var value any
    if err := json.Unmarshal(src, &value); err != nil {
        log.Fatal(err)
    }

    // Parse the SQL-standard jsonpath query.
    p, err := path.Parse(`$.track.segments[*] ? (@.HR > 130)."start time"`)
    if err != nil {
        log.Fatal(err)
    }

    // Execute the query against the JSON.
    items, err := p.Query(context.Background(), value)
    if err != nil {
        log.Fatal(err)
    }

    // Print the results.
    fmt.Printf("%v\n", items)
    // Output: [2018-10-14 10:39:21]
}

See the path README for a complete description of the SQL/JSON path language, and the Go doc for usage and examples.

Or take the 🛝 Playground for a spin (direct link for above example). Implemented as a single-page stateless JavaScript and TinyGo-compiled Wasm app.

Strict No LLM/No AI Policy

This software is 100% made by humans for humans and welcomes human contributions. That means:

  • No LLM-generated content, whether it be code or prose.
  • No paraphrasing LLM-generated content.
  • No LLMs for editing, including fixing spelling or grammatical errors.
  • No LLMs for translation. English is encouraged, but not required. You are welcome to post in your native language and rely on others to have their own translation tools of choice to interpret your words.
  • No LLMs for brainstorming and then sharing the results of that brainstorming, even if you create the prose. If you use a chatbot to give you advice on a comment on the issue tracker, that comment is unwelcome.
  • No LLMs for finding bugs.
  • No talking about use of chatbot/LLM services.

Borrowed from the Zig Code of Conduct.

Copyright

Copyright © 1996-2025 The PostgreSQL Global Development Group

Copyright © 2024-2026 David E. Wheeler

About

PostgreSQL-compatible SQL-standard SQL/JSON in Go

Topics

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages