emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Improving JSON pretty printing, how to represent floats?


From: Herman , Géza
Subject: Improving JSON pretty printing, how to represent floats?
Date: Fri, 05 Apr 2024 11:39:10 +0200

Hi,

I'm thinking about using the new JSON parser and encoder for json-pretty-print.

There is a thing that I don't like about the current json-pretty-print: as it parses floats, pretty printing can be lossy. If one pretty prints this

--8<---------------cut here---------------start------------->8---
{
   "a": 3.333333333333000000000000000001
}
--8<---------------cut here---------------end--------------->8---

then the float gets rounded. I think pretty printing should be lossless (keeping the exact format, exp notation, etc.).

What would be the best representation for numbers in this case? I'm thinking about using symbols, but I'm not sure this is the best approach. The parser/encoder would have a new keyword parameter, like ":numbers-as-symbols t". If this is specified, then numbers wouldn't be parsed, but kept as symbols. What do you think, is this a good approach?

Geza



reply via email to

[Prev in Thread] Current Thread [Next in Thread]