Skip to content

JSON standard library type #58

@aallan

Description

@aallan

JSON should be a standard library ADT, not a primitive type:

data Json {
  JNull,
  JBool(Bool),
  JNumber(Float),
  JString(String),
  JArray(Array<Json>),
  JObject(Map<String, Json>)
}

Parse and serialize operations belong in the standard library. Refinement types can express JSON schemas (e.g., type ApiResponse = { @Json | has_field(@Json.0, "status") }). This approach keeps the core language small while providing ergonomic JSON support.

Depends on: Standard library collections (#Map type).

Spec reference: spec/00-introduction.md § 0.8 "JSON as a Standard Library Type"

Metadata

Metadata

Assignees

No one assigned

    Labels

    C9C9 — Language designdesignFuture language design (spec §0.8)enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions