Skip to content

Add JsonPrinter for serializing any JsonValue#5084

Closed
SeanTAllen wants to merge 1 commit into
mainfrom
seantallen/json-printer
Closed

Add JsonPrinter for serializing any JsonValue#5084
SeanTAllen wants to merge 1 commit into
mainfrom
seantallen/json-printer

Conversation

@SeanTAllen

Copy link
Copy Markdown
Member

Demonstration of the approach discussed in ponylang/rfcs#223.

Rather than a Json wrapper primitive that re-wraps JsonParser.parse() and adds a print() method, this exposes a JsonPrinter primitive that mirrors JsonParser:

  • JsonPrinter.print(value) — compact JSON serialization of any JsonValue
  • JsonPrinter.pretty(value) — pretty-printed serialization with configurable indent

Both delegate to the existing _JsonPrint internal primitive. JsonParser, JsonObject.string(), and JsonArray.string() are unchanged.

This fills the gap where _JsonPrint already handles all JsonValue variants correctly (proper null for None, escaped/quoted strings, etc.) but isn't accessible to users.

Demonstrates the approach discussed in ponylang/rfcs#223 — expose
_JsonPrint's functionality through a public JsonPrinter primitive
with print() and pretty() methods, rather than the Json.print()
wrapper proposed in the RFC.
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Mar 28, 2026
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Mar 28, 2026
@SeanTAllen

Copy link
Copy Markdown
Member Author

Closing as this was opened to generate conversation around an RFC. It has served its purpose.

@SeanTAllen SeanTAllen closed this May 1, 2026
@ponylang-main ponylang-main added discuss during sync Should be discussed during an upcoming sync and removed discuss during sync Should be discussed during an upcoming sync labels May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants