If you're just trying to work with the decimal numbers in PicoLisp, then
why not just use fixed-point?
You can modify my json.l and specify a 20 digit decimal, and then parse
your file. The result will be strings instead of numbers, but it works fine. Here's a
patch:
diff --git a/json.l b/json.l
index 551e3a9..a135c39 100644
--- a/json.l
+++ b/json.l
@@ -6,6 +6,8 @@
(setq *Json_control_characters (extract '((N) (unless (member N '("^H"
"^L" "^J" "^M" "^I")) N)) (mapcar char (range 1 31))))
+(scl 20)
+
# send error message to STDERR
[de json-err-throw (Error)
(msg Error)
@@ -112,7 +114,7 @@
((= "[" Type) (make (link T) (json-link-array)))
((= "{" Type) (make (json-link-object)))
((lst? Type) (pack Type))
- ((num? Type) Type)
+ ((num? Type) (format Type *Scl))
((= "-" Type) (if (num? (car *Json)) (format (pack "-" (pop
'*Json))) (json-iterate-object)))
((= 'true Type) 'true)
((= 'false Type) 'false)
-- Try that against my latest git commit to
https://github.com/aw/picolisp-json (tag v4.0.0)
AW
On Wed, 8 May 2019, C K Kashyap wrote:
Perfect!!!! - It is pure bliss to see such concise code.
Regards,
Kashyap
On Wed, May 8, 2019 at 6:59 AM Alexander Burger <a...@software-lab.de> wrote:
On Wed, May 08, 2019 at 09:17:54AM +0200, Alexander Burger wrote:
Yes, "123.0.0" is not a legal number.
I am sure there must a better way to do the lengthy "0"..."9" that I've
done :)
The best is to avoid at all looping over the characters, because built-ins
are a
lot faster than individual function calls in a loop.
What I would do here is
(pipe
(in '("curl" "-s" "
https://api.iextrading.com/1.0/stock/aapl/chart/3m")
(while
(prin
(echo "close" "volume" "unadjustedVolume") )
(when (prin (till "," "}"))
(or (sub? "." @) (prin ".")) ) ) )
(readJson) )
The trick is to read the digits with 'till', print them, and *then* check
if a
dot is needed.
☺/ A!ex
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe