Re: app builder from JSON

2019-05-22 Thread Abel Normand
From: bpsun...@gmail.comSent: 22 May 2019 10:23To: picolisp@software-lab.deReply to: picolisp@software-lab.deSubject: app builder from JSON hello,i have a question to pose to this group, lets assume that I have

app builder from JSON

2019-05-22 Thread sundar bp
hello, i have a question to pose to this group, lets assume that I have a JSON schema with TAB layout given by the end user, {"tab1": "name": {"type": "string", "length": "25"}, "contact": {"type" : "number"

Re: Review request for my JSON parsing implementation

2019-05-12 Thread C K Kashyap
,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) >

Re: Review request for my JSON parsing implementation

2019-05-10 Thread Alexander Burger
On Fri, May 10, 2019 at 07:19:06AM -0700, C K Kashyap wrote: > Interestingly sub? also seems to work like member? Ah, right. I forgot. 'sub?' is rather tolerant, it accepts also non-symbolic values and converts them silently to transients ;) > member? is clearly the appropriate one. Yes, and

Re: Review request for my JSON parsing implementation

2019-05-10 Thread C K Kashyap
Thanks Alex, "apply" is what I was looking for :) Interestingly sub? also seems to work like member? for list of chars - but member? is clearly the appropriate one. I think trim is required because this is valid {"K1": 10 , "K2": 20} Regarding the download logic - the idea is to cache the

Re: Review request for my JSON parsing implementation

2019-05-10 Thread Alexander Burger
On Fri, May 10, 2019 at 07:38:22AM +0200, Alexander Burger wrote: >(de getJson (Spl File Url Oln) > (when (or Oln (not (info File))) > (wget Url) ) > (pipe > (in File I think this whole construct is not wise. What if the file fetched with 'wget' has a different

Re: Review request for my JSON parsing implementation

2019-05-09 Thread Alexander Burger
On Thu, May 09, 2019 at 03:39:32PM -0700, C K Kashyap wrote: > (de getJson (Spl File Url Oln) > (unless (info File) (on Oln)) > (when Oln (out File (wget Url))) > (pipe >(in File > (while >(prin > (run (list (cons 'echo Spl >(when (till (list "," "}")) >

Re: Review request for my JSON parsing implementation

2019-05-09 Thread C K Kashyap
I am not sure if I should start a new thread for this question - but since it's building off of reading json, I decided to continue this thread :) (de getJson (Spl File Url Oln) (unless (info File) (on Oln)) (when Oln (out File (wget Url))) (pipe (in File (while (prin

Re: Review request for my JSON parsing implementation

2019-05-09 Thread Alexander Williams
/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 t

Re: Review request for my JSON parsing implementation

2019-05-08 Thread C K Kashyap
Perfect - It is pure bliss to see such concise code. Regards, Kashyap On Wed, May 8, 2019 at 6:59 AM Alexander Burger 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

Re: Review request for my JSON parsing implementation

2019-05-08 Thread Alexander Burger
On Tue, May 07, 2019 at 05:26:57PM -0700, C K Kashyap wrote: > I ended up making the code less pretty. Looks like the suffix ".0" must > only be added if the number is not already in floating point format. Yes, "123.0.0" is not a legal number. > (setq J > (pipe >(in '("sh" "-c" "curl -s >

Re: Review request for my JSON parsing implementation

2019-05-07 Thread C K Kashyap
I ended up making the code less pretty. Looks like the suffix ".0" must only be added if the number is not already in floating point format. (setq J (pipe (in '("sh" "-c" "curl -s https://api.iextrading.com/1.0/stock/aapl/chart/3m;) (while (case (echo "close" "volume"

Re: Review request for my JSON parsing implementation

2019-05-07 Thread andreas
You would also include "[" in the 'echo' arguments, then check it with (use S (while (prin (setq S (echo "[" "volume" "unadjustedVolume") ) ) (if (= "[" S) (... step through the elements ...) (echo ",")

Re: Review request for my JSON parsing implementation

2019-05-07 Thread C K Kashyap
Oh yes ... I can see how that would work!!! ... thanks Alex. echo seems like a nice function - I don't think I've seen it anywhere before :) (I mean, I've seen echo that's equivalent of printf ... but not this) Regards, Kashyap On Tue, May 7, 2019 at 8:49 AM Alexander Burger wrote: > On Tue,

Re: Review request for my JSON parsing implementation

2019-05-07 Thread Alexander Burger
On Tue, May 07, 2019 at 08:13:32AM -0700, C K Kashyap wrote: > Actually my point about array was to read the numbers in the array as fixed > points decimals :) - 1, 2.0,3 -> with correct scaling. Ah, ok, this must be handled separately. You would also include "[" in the 'echo' arguments, then

Re: Review request for my JSON parsing implementation

2019-05-07 Thread C K Kashyap
> > 2. use (echo "," "}") so that it works with values that are the last > entry > > in the dictionary > > Right! Then remember it locally to output again. > > Instead of > >(echo ",") > (prin ".0,") > > you

Re: Review request for my JSON parsing implementation

2019-05-07 Thread Alexander Burger
uot;," "}") so that it works with values that are the last entry > in the dictionary Right! Then remember it locally to output again. Instead of (echo ",") (prin ".0,") you can do (and (echo "," "}") (prin ".0" @) As a benefit,

Re: Review request for my JSON parsing implementation

2019-05-07 Thread C K Kashyap
Yeah ... and each line is lot fewer than 80 characters :) just to confirm that I got it - I believe that a couple of changes are needed to make it work better - 1. use (echo "\"volume\"") - this way any "volume" inside a string will not be confused 2. use (echo "," "}") so that it works with

Re: Review request for my JSON parsing implementation

2019-05-07 Thread Guido Stepken
Some also call it "REST" and have written mighty libraries in other languages. In PicoLisp it's a 5 - liner! ;-) Alexander Burger schrieb am Di., 7. Mai 2019, 07:04: > On Mon, May 06, 2019 at 02:06:56PM -0700, C K Kashyap wrote: > > My mind is blown - yet again. I love it just looking at it.

Re: Review request for my JSON parsing implementation

2019-05-06 Thread Alexander Burger
On Mon, May 06, 2019 at 02:06:56PM -0700, C K Kashyap wrote: > My mind is blown - yet again. I love it just looking at it. I'll have to > look a little more to see what's going on. > > How do I capture the output though - I mean this does not capture the > output in J I used 'pretty' in the

Re: Review request for my JSON parsing implementation

2019-05-06 Thread C K Kashyap
My mind is blown - yet again. I love it just looking at it. I'll have to look a little more to see what's going on. How do I capture the output though - I mean this does not capture the output in J (setq J (pipe (in '("curl" "-s" "https://api.iextrading.com/1.0/stock/aapl/chart/3m ")

Re: Review request for my JSON parsing implementation

2019-05-06 Thread Alexander Burger
On Mon, May 06, 2019 at 10:21:34PM +0200, Alexander Burger wrote: >(pipe > (in '("curl" "-s" "https://api.iextrading.com/1.0/stock/aapl/chart/3m;) > (while > (prin >(echo "volume" "unadjustedVolume") ) > (echo ",") > (prin

Re: Review request for my JSON parsing implementation

2019-05-06 Thread C K Kashyap
bad - infact, the > > solution i was trying was to simply add a ".0" to all the numbers that > did > > not have it. > > Yes, can be done with the above 'sed'. > > But only if you are sure that none of the numbers is meant to be a plain > integer. > > &g

Re: Review request for my JSON parsing implementation

2019-05-06 Thread Alexander Burger
ers that did > not have it. Yes, can be done with the above 'sed'. But only if you are sure that none of the numbers is meant to be a plain integer. > Also, would it not be okay to say that all the numbers in the JSON (or some > other input) are scaled? It's for the user to be aware an

Re: Review request for my JSON parsing implementation

2019-05-06 Thread C K Kashyap
it. Also, would it not be okay to say that all the numbers in the JSON (or some other input) are scaled? It's for the user to be aware and deal with it appropriately. On Mon, May 6, 2019 at 6:47 AM Alexander Burger wrote: > Hi Kashyap, > > > I still have a question - if my > > pro

Re: Review request for my JSON parsing implementation

2019-05-06 Thread Alexander Burger
Hi Kashyap, > I still have a question - if my > program gets its input from two json strings - > {"V": 10} and {"V" : 10.1}, and I need to sum up all the Vs - how can I do > it? I think there is no generic solution. It all depends on what the numbers *mean*.

Re: Review request for my JSON parsing implementation

2019-05-05 Thread C K Kashyap
Interesting ... for some reason, I believed that PicoLisp did not contain a json parser !!! - perhaps because, a search for json on https://picolisp.com/wiki/?Documentation takes me to the external repositories section :) pipe is awesome :) - I was looking for just that. It occurred to me

Re: Review request for my JSON parsing implementation

2019-05-05 Thread Alexander Burger
On Sat, May 04, 2019 at 11:27:28PM -0700, C K Kashyap wrote: > Thank you so much Alex ... What would it take to transform this code to > handle string as input instead of file stream? There are two ways: 1. To parse strings directly, then a different code is needed. As an example, see

Re: Review request for my JSON parsing implementation

2019-05-05 Thread C K Kashyap
Thank you so much Alex ... What would it take to transform this code to handle string as input instead of file stream? On Sat, May 4, 2019 at 11:17 PM Alexander Burger wrote: > On Sun, May 05, 2019 at 07:58:16AM +0200, Alexander Burger wrote: > > Hi Kashyap, > > > > > Gentle reminder :) > > ...

Re: Review request for my JSON parsing implementation

2019-05-05 Thread Alexander Burger
On Sun, May 05, 2019 at 07:58:16AM +0200, Alexander Burger wrote: > Hi Kashyap, > > > Gentle reminder :) > ... > > > (while (not (= (peek) "\"")) > > Better (until (= (peek) "\"") Like what I said about 'prog', also 'not' should seldom be necessary. At least *never* in conditionals. ☺/

Re: Review request for my JSON parsing implementation

2019-05-05 Thread Alexander Burger
Hi Kashyap, > Gentle reminder :) Yeah, good! :) I think it looks good, not much to say on a short glance. *If* anything at all, I would only mention minor stuff like > > (while (not (= (peek) "\"")) Better (until (= (peek) "\"") > > (case (peek) > >("\\" (char) (link

Re: Review request for my JSON parsing implementation

2019-05-04 Thread C K Kashyap
Gentle reminder :) On Fri, May 3, 2019 at 6:24 PM C K Kashyap wrote: > Hi all, > I've made an attempt at JSON parsing. I did this since json.l at > https://github.com/aw/picolisp-json does not handle floating numbers and > that is something I need. I also took it as an opportunity

Review request for my JSON parsing implementation

2019-05-03 Thread C K Kashyap
Hi all, I've made an attempt at JSON parsing. I did this since json.l at https://github.com/aw/picolisp-json does not handle floating numbers and that is something I need. I also took it as an opportunity to implement something bigger than a function and get some feedback about it - I used xml.l

Re: JSON lib rewritten in pure PicoLisp - no C/ffi bindings

2018-01-11 Thread Alexander Williams
By popular demand, I've published a **new** EXPLAIN document regarding this JSON library. Feel free to read: https://github.com/aw/picolisp-json/blob/master/EXPLAIN_v3.md AW On 01/10/2018 05:19 AM, r...@tamos.net wrote: > Thanks, aw!  Your EXPLAINs are something I always look forw

Re: JSON lib rewritten in pure PicoLisp - no C/ffi bindings

2018-01-10 Thread Alexander Williams
*fistbump* On 01/10/2018 05:19 AM, r...@tamos.net wrote: > Thanks, aw!  Your EXPLAINs are something I always look forward to > reading, and this one did not disappoint. I also like your style of > coding. As an aside, I smiled when you mentioned PAIP. I love this book > too!  All the best, —Rick

Re: JSON lib rewritten in pure PicoLisp - no C/ffi bindings

2018-01-09 Thread rick
Thanks, aw! Your EXPLAINs are something I always look forward to reading, and this one did not disappoint. I also like your style of coding. As an aside, I smiled when you mentioned PAIP. I love this book too! All the best, —Rick

Re: JSON lib rewritten in pure PicoLisp - no C/ffi bindings

2018-01-09 Thread Alexander Williams
I discovered a bug in v3.0 of the parser, so I took that opportunity to add more tests; as well as refactor, simplify, and optimize the code (and fix the bug). Latest version can be obtained here: https://github.com/aw/picolisp-json/blob/master/json.l Thanks! AW On 01/08/2018 10:18 AM

Re: JSON lib rewritten in pure PicoLisp - no C/ffi bindings

2018-01-08 Thread Pontus Näslund
awesome, thanks Den 8 jan. 2018 11:26 fm skrev "Alexander Williams" <a...@unscramble.co.jp>: > Hi everyone, > > I've published a significant change to my picolisp-json[1] library. The > decoder, now at version 3.0, has been completely rewritten to avoid

JSON lib rewritten in pure PicoLisp - no C/ffi bindings

2018-01-08 Thread Alexander Williams
Hi everyone, I've published a significant change to my picolisp-json[1] library. The decoder, now at version 3.0, has been completely rewritten to avoid the use of a C/ffi library. This means it also works on 32-bit systems. I've added ~30 unit tests[2] to validate various edge cases

Yet another JSON lib, and a tutorial

2015-03-10 Thread Alexander Williams
Hi list, I've written yet another JSON encoder/decoder for PicoLisp. I know, they already exist.. This library is using a native C library for JSON parsing, so it's a bit different. Of course, I've written a tutorial which explains a few more concepts I learned (Thanks Mr. Burger). https

Re: JSON Rest

2014-02-17 Thread Henrik Sarvell
This encoder/decoder is based on Alex's rosetta example https://bitbucket.org/hsarvell/ext/src/31f26bbff901e1a88aa997ce919b7edb50ea810d/json.l?at=defaultbut has turned out quite changed to automatically account for various edge cases. With this CURL based client you can post the JSON straight

Re: json example w/ersatz

2012-01-30 Thread Alexander Burger
Hi Joe, Are there any tips on how to port the json example to ersatz since it does not support pipe? I experimented with parsing out the string into a new string and calling str on it but didn't get very far yet. I'd like something that can parse a string. The function 'str' is the brother

json example w/ersatz

2012-01-29 Thread Joe Bogner
Are there any tips on how to port the json example to ersatz since it does not support pipe? I experimented with parsing out the string into a new string and calling str on it but didn't get very far yet. I'd like something that can parse a string. Thanks Joe -- UNSUBSCRIBE: mailto:picolisp

Bug in the JSON example in rosetta

2012-01-27 Thread José Romero
Looks like the example JSON functions choke on empty objects. I made a quick and dirty fix, but I'm not sure if I introduced extra bugs. Diff follows: ## --- json.orig.l 2012-01-27 07:34:25.0 -0300 +++ json.l 2012-01

Re: Bug in the JSON example in rosetta

2012-01-27 Thread José Romero
On Fri, 27 Jan 2012 12:55:29 +0100 Alexander Burger a...@software-lab.de wrote: Hi José, Looks like the example JSON functions choke on empty objects. I made a Oops. Right. If it's OK I'll edit the task page, buggy code is ugly code! Indeed. Please do so. Many thanks! Done

Re: Bug in the JSON example in rosetta

2012-01-27 Thread Alexander Burger
Hi José, Hmmm, it still doesn't work quite well, it chokes on negative Oops again ;-) numbers, no idea how to fix that. :( We can simply add the - character to the atom-specifiers: (de readJson () (case (read -_) ({ ... Cheers, - Alex -- UNSUBSCRIBE:

Re: Bug in the JSON example in rosetta

2012-01-27 Thread Alexander Burger
On Fri, Jan 27, 2012 at 01:45:12PM +0100, Alexander Burger wrote: We can simply add the - character to the atom-specifiers: Sorry, forget that. These are only for symbols :( Let me check more thoroughly. Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Re: Bug in the JSON example in rosetta

2012-01-27 Thread José Romero
On Fri, 27 Jan 2012 13:58:50 +0100 Alexander Burger a...@software-lab.de wrote: On Fri, Jan 27, 2012 at 01:48:41PM +0100, Alexander Burger wrote: Let me check more thoroughly. How about that? (de readJson () (case (read _) ... (T (let X @

JSON

2010-08-26 Thread Alexander Burger
Hi all, for the fans of JSON: I wrote a simple library (if we should call such a trivial thing a library ;-) http://rosettacode.org/wiki/JSON Cheers, - Alex -- UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Re: JSON

2010-08-26 Thread Henrik Sarvell
Some documentation: http://www.prodevtips.com/2008/09/11/pico-lisp-and-json= / Hm I just realized there's a dependency to a class called +Str, here is the function being used: (dm entityQuotes (S) (pack (mapcar '((C) (if (=3D 34 (char C)) quot; C )) (chop S Seems

Re: JSON

2010-08-26 Thread Alexander Burger
Hi Henrik, I suppose I have to refer to my own stuff for completeness here too then. Yes. Though I knew about your work, and we've discussed it in the past, I must confess that I didn't remember it when I saw the RosettaCode task today. Your library is much more general and complete. Yet, for

JSON

2009-12-14 Thread Henrik Sarvell
I just noticed that someone had searched for picolisp json on Google, I've attached the JSON encoder/decoder to this mail. However there is one problem, it isn't properly managing when there are complex texts involved, then the double quote escaping might get it wrong if there are already escaped

Re: JSON

2009-12-14 Thread Benjamin Pollack
modules before I dove in. I found your post about processing PicoLisp client-side rather than working with JSON server-side, and the one where you wrote that you gave up, and were going to shell out to Ruby for HTML escapes. An interesting combination. Thanks very much for the encoder. I haven't

Re: JSON

2009-12-14 Thread Henrik Sarvell
I use the JSON library extensively on vizreader.com so I know it works for most things, actually the text I mentioned before that broke it contained javascript inside it I think. As for the tag stripping I'm actually only using PHP-cli for all my needs at the moment, leaving Ruby out

Re: From Pico to JSON in the client

2009-09-16 Thread Henrik Sarvell
It worked out OK with the :key rule, however in the end I went for prefuse flare, not processing for my visualizations and was irritated by having to change (processingjs is too slow) so I skipped the Actionscript 3 implementation, I'm just outputting JSON in picolisp now straight away which works

Re: From Pico to JSON in the client

2009-09-16 Thread TC
On Wed, 16 Sep 2009, Tomas Hlavaty wrote: Hi Henrik and TC, I just realized that there is an ambiguity here since I can't seem to accomplish a pair looking like this: (key . (1 2 3)), no matter how I try I get: (key (1 2 3)), if the Heh, I think the problem is quite obvious when looking to

Re: From Pico to JSON in the client

2009-09-06 Thread Henrik Sarvell
a bias to lean on as an extra argument but that doesn't feel 100% right. I can't see how :key would create any conflicts either. /Henrik On Fri, Sep 4, 2009 at 8:23 AM, Tomas Hlavatyt...@logand.com wrote: Hi Henrik, First of all, to offload the server from having to build json all the time

Re: From Pico to JSON in the client

2009-09-04 Thread Tomas Hlavaty
Hi Henrik, First of all, to offload the server from having to build json all the time. your server must be very popular when it struggles to generate json;-) 1) Parsing sexp: function parse(S) in http://ondoc.logand.com/ondoc.js 2) Parsing PDFs in OnDoc: works surprisingly well fast

Re: From Pico to JSON in the client

2009-09-04 Thread Henrik Sarvell
, First of all, to offload the server from having to build json all the time. your server must be very popular when it struggles to generate json;-) 1) Parsing sexp: function parse(S) in http://ondoc.logand.com/ondoc.js 2) Parsing PDFs in OnDoc: works surprisingly well fast in picolisp. 3) Parsing

Re: From Pico to JSON in the client

2009-09-03 Thread Henrik Sarvell
...@software-lab.de wrote: On Thu, Sep 03, 2009 at 02:00:39AM +0200, Henrik Sarvell wrote: http://www.prodevtips.com/2009/09/02/pico-lisp-to-json-with-javascript/ ... two issues but I don't know about the rest of you, any ideas? I believe it is difficult to parse nested Lisp data with static

Re: From Pico to JSON in the client

2009-09-03 Thread Mateusz Jan Przybylski
Hello, On Thursday 03 September 2009 02:00:39 Henrik Sarvell wrote: Hello everyone, I sat down tonight and ugly coded a Pico to JSON converter in JS, I documented it here: http://www.prodevtips.com/2009/09/02/pico-lisp-to-json-with-javascript/ Pretty nifty idea IMHO :) The part of your

Re: From Pico to JSON in the client

2009-09-03 Thread Henrik Sarvell
Thanks Mateusz, I'll try it out. /Henrik On Thu, Sep 3, 2009 at 11:52 AM, Mateusz Jan Przybylskidexen.devr...@gmail.com wrote: Hello, On Thursday 03 September 2009 02:00:39 Henrik Sarvell wrote: Hello everyone, I sat down tonight and ugly coded a Pico to JSON converter in JS, I documented

Re: From Pico to JSON in the client

2009-09-03 Thread Henrik Sarvell
First of all, to offload the server from having to build json all the time. For me the real issue is not speed in the client, given that premise I simply took a wild guess that building the json and then evaluating it is a simpler road to take than actually building the composite objects right

Re: From Pico to JSON in the client

2009-09-03 Thread Henrik Sarvell
I just realized that there is an ambiguity here since I can't seem to accomplish a pair looking like this: (key . (1 2 3)), no matter how I try I get: (key (1 2 3)), if the first one is really impossible then any JSON converter will stumble on it since it's impossible to know if [key, [1, 2, 3

Re: From Pico to JSON in the client

2009-09-03 Thread TC
it really is: a chain of cons. (key (1 2 3)) - (key . ((1 . (2 . (3 . NIL) that's equivalent to: (key . (1 2 3)) = (key (1 2 3)) first one is really impossible then any JSON converter will stumble on it since it's impossible to know if [key, [1, 2, 3]] or {key: [1, 2, 3]} is the desired