From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Herman=2C_G=C3=A9za?= Newsgroups: gmane.emacs.devel Subject: Improving JSON pretty printing, how to represent floats? Date: Fri, 05 Apr 2024 11:39:10 +0200 Message-ID: <87msq8w2zm.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39732"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Apr 05 11:53:39 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rsgGQ-000A56-Dx for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Apr 2024 11:53:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsgFQ-0000ST-IO; Fri, 05 Apr 2024 05:52:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsgFP-0000S1-5h for emacs-devel@gnu.org; Fri, 05 Apr 2024 05:52:35 -0400 Original-Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsgFN-0004LI-Kc for emacs-devel@gnu.org; Fri, 05 Apr 2024 05:52:34 -0400 Original-Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4162b0e21b0so9652425e9.0 for ; Fri, 05 Apr 2024 02:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712310751; x=1712915551; darn=gnu.org; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=fxquJhQ1C02H3LnuTmVzt7KPHzMzY3OQNfy/IXo7oX4=; b=JZldirS1EEBZ2G2/17u5zlntgjP+gSC/yD5BFAddCXkPvrKdk0V2gbqqOEXONecpQQ lF1dJzYdg6B2j8e6mqecs0mgjR/vHj2PmBvudwXbkfD3ChBuoW3Tz4nloJybusl9ngaP SL+IrT6TkeEX0lz+yV3qKPjMU95GnJWfKyQuF6SRV8sWQwCtG8Vb2unuSyINPUlAEPoQ TnpWKIPrCd3VZ3qRufUA5UoQ1qZE8asxSr5arbup4P5mISu64hYuT6xmXCzDp9FqeKa7 9vgwWAEZJ7XJU23IFS6aegFr/NdsfpL+ggI/lCBZD4Smd5wdoSMaCWUj0ekU6g88M/24 bcPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712310751; x=1712915551; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fxquJhQ1C02H3LnuTmVzt7KPHzMzY3OQNfy/IXo7oX4=; b=oHENV+eZD73IrACs21iriNSF+tH1Lx56Yvm8uMzHWXq3a1HK1QvqZAy+XFUmkaBFM8 9BrEiRuA4jTCq1fFAJHgCCOr22sFmvJWbisCnUdDBmFeV+Sm+mfPWg1z0y6xLYNxTco2 r6bALhXrHh7ZP0WPDGV07K7rVwNmcakbWx5L+63LAQsRZeJHbz82IWL8wxF/P8votXcs 7z2NaTFuMYYUUEM6HASVQrhJHQiavKDnleFf1Bnbu4N3SXy51Ebg/w6zs3ijz/FZtlM7 4BxiPkpLpvxX9Di0MDnsksbvOnoZHZmw3CAaoJRdVnX4AZ6ghKhwG7Erz3YLhOt8rGUV DEeg== X-Gm-Message-State: AOJu0YxizYZL1LagmcsQRRFAkNIq/FHvfraco7r7nWniWNKCALfTOznH GTFa1e9qbd9vLh4YnaRUiB6gGm3HWWcjYuTnhBAoZv5xECBKLYP2uVFcGeln X-Google-Smtp-Source: AGHT+IEStNu1NWaDDOvYLWqXM84dqW4RqzFHbH5ACvkCEPn/5ix2+jlL2FnPAtj11BI4r3IR3a0uhA== X-Received: by 2002:adf:f449:0:b0:343:6cf9:9e38 with SMTP id f9-20020adff449000000b003436cf99e38mr718825wrp.20.1712310751266; Fri, 05 Apr 2024 02:52:31 -0700 (PDT) Original-Received: from localhost (netacc-gpn-4-112-243.pool.yettel.hu. [84.224.112.243]) by smtp.gmail.com with ESMTPSA id o13-20020a5d58cd000000b00341b7d5054bsm1611374wrf.72.2024.04.05.02.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 02:52:30 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=geza.herman@gmail.com; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:317538 Archived-At: 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