ygrek has quit [Remote host closed the connection]
<
abu[7]>
Hi tankf33der!
<
abu[7]>
Can't it be simpler? Do you flatten only the top level?
<
abu[7]>
Otherwise 'fish'
<
tankf33der>
Only top
<
abu[7]>
You could (or (pair L) (list L))
<
tankf33der>
I am building curl call list and supporting -u credentials only if passed
<
tankf33der>
I have built picolisp library for monero-wallet-rpc daemon. Very flexible. Now i could do whatever i want to.
<
tankf33der>
Simple example of usage
<
tankf33der>
i like this
<
abu[7]>
Yeah, but this goes deeper (not only top level)
<
tankf33der>
i have maximum 1 level: ("1" ("2" "3") "4")
rob_w has joined #picolisp
rob_w has quit [Ping timeout: 252 seconds]
<
tankf33der>
abu[7]: here or meeting ?
<
abu[7]>
Meeting in 2 h
<
tankf33der>
ok. no hurry
<
abu[7]>
No problem. A difficult question?
<
tankf33der>
can not make a array of objects from @lib/json.l
<
abu[7]>
'printJson' ?
<
tankf33der>
{"id": "0", "params": {"dests": {"amount": 1, "address": "aaa"}}}
<
abu[7]>
hmm, an older version had an "array" flag arg, but this is gone
<
tankf33der>
dests must be array
<
tankf33der>
array of objects..
<
abu[7]>
works only for atoms
<
abu[7]>
str or num
<
tankf33der>
damn. eh.
<
abu[7]>
I don't remember why this was removed
<
tankf33der>
this is bad for me.
<
abu[7]>
We should revert
<
abu[7]>
it was somewhen in pil64
<
abu[7]>
still in latest pil64
<
tankf33der>
yes, please. i will use it
<
abu[7]>
Can you try with json.l from 24nov16abu
<
abu[7]>
if it makes sense?
<
abu[7]>
Do you have it?
<
abu[7]>
or should I paste?
<
tankf33der>
i will copy from github's repo
<
abu[7]>
Can you investigate if we can revert?
<
abu[7]>
import some fragments?
<
abu[7]>
The 'Arr' and 'T' stuff
<
tankf33der>
jsonOLD is beaking everything. new library - new knowledge how to use it. jsonrpc returns "Parse error" out of box
<
abu[7]>
That's why I say we need to import fragments
<
abu[7]>
the other parts are ok
<
abu[7]>
I don't remember why we removed it
<
abu[7]>
was not satisfactory somehow
<
abu[7]>
For printJson it just needs ((=T (car Item)) and (cdr Item)
<
abu[7]>
Shall I re-introduce into pil21?
<
tankf33der>
yeap. try
<
abu[7]>
Why was this feature removed?
<
tankf33der>
its not me.
<
abu[7]>
I hope it does not conflict
<
tankf33der>
do you use it somewhere ?
<
tankf33der>
you can test firstly
<
abu[7]>
I newer used the array feature iirc
<
tankf33der>
this code breaks anyway with old json
<
tankf33der>
i imagine "address" will be array of objects
<
abu[7]>
let me re-import Arr
<
abu[7]>
needs alsp parse
<
abu[7]>
packJson I mean
<
abu[7]>
Can you try?
<
tankf33der>
i will named jsonNEW
<
tankf33der>
i will named jsonNEW.l
<
tankf33der>
not breaking current code
<
tankf33der>
good sign
<
tankf33der>
and where i should put T ?
<
abu[7]>
Cons it to a list that should be printed as array
<
abu[7]>
OK, I also adjusted 'packJson'
<
tankf33der>
how to modify this code to make dests an array
<
abu[7]>
(list T '(id . "0") (list 'params ..
<
tankf33der>
hm. now working. checking
<
tankf33der>
[{"5927829442663": !? (cdar X)
<
tankf33der>
id -- List expected
<
abu[7]>
Hmm, it should work as before
<
tankf33der>
i never use json until this week.
<
tankf33der>
and never touched in pil too
<
abu[7]>
Can you investigate more?
<
tankf33der>
i will try, but you see on your side ?
<
tankf33der>
run this code with newer version
<
tankf33der>
with (list T ...
<
tankf33der>
works ?
<
abu[7]>
{"id": "0", "params": {"dests": {"amount": 1, "address": "aaa"}}}-> "}"
<
tankf33der>
with list T ?
rob_w has joined #picolisp
<
abu[7]>
It has no T
<
tankf33der>
copy paste your code
<
tankf33der>
please
<
abu[7]>
I get an error
<
abu[7]>
Item is (id . "0")
<
abu[7]>
We should now have the same as old pil
<
tankf33der>
pil64 ?
<
abu[7]>
is (id . "0") wrong syntax?
<
abu[7]>
I don't remember
<
tankf33der>
i thought now.
<
tankf33der>
(cons 'id "0") or '(id . "0")
<
tankf33der>
i thought yes, correct
<
tankf33der>
but i do not have much correct examples. i reverse engineered library to understand how it is working. :(
<
abu[7]>
The code of ((=T (car Item)) and (T is different
<
abu[7]>
(printJson (car X)) vs (printJson (cdar X))
<
abu[7]>
and (prin "\"") etc.
<
abu[7]>
So old version was not right?
<
abu[7]>
Or different meanang?
<
tankf33der>
i can not use it with T
<
tankf33der>
jsonNEW.l i meant
<
abu[7]>
but what is correct?
<
abu[7]>
should the cond clauses be the same?
<
abu[7]>
ok, I change
<
tankf33der>
i am on jsonNEW.l right now.
<
tankf33der>
and need support for arrays.
<
tankf33der>
(list T 'dests ...)
<
abu[7]>
Same logic
<
tankf33der>
will be jsonNEW.l on my side
<
abu[7]>
for both clauses
<
abu[7]>
needs also packJson
<
abu[7]>
I will release
<
tankf33der>
code is working out of box so far
<
tankf33der>
and how to enable arrays on jsonNEW.l ?
<
tankf33der>
or what i testing ? :)
<
abu[7]>
Code for both clauses is redundant now
<
abu[7]>
should rewrite as 'if'
<
abu[7]>
Sorry, no time
<
abu[7]>
Can you investigate more?
<
abu[7]>
The correct way for print and pack?
<
tankf33der>
arrays ?
<
abu[7]>
I want to release then
<
tankf33der>
eh. this is beyond me.
<
abu[7]>
No, you understand that
<
abu[7]>
I can't concentrate atm
<
abu[7]>
phone calls all the time
<
abu[7]>
and meeting soon all afternoon
<
abu[7]>
Thanks!! ☺
<
tankf33der>
no hurry
<
abu[7]>
I think the code of json.l is no magic
<
tankf33der>
fucking recursion, this is my weak spot
<
abu[7]>
I wll look at it this evening. Perhaps the whole thing needs to be done differently
<
abu[7]>
parseJson and readJson are OK?
<
tankf33der>
seems so
<
tankf33der>
i found json testsuite from Nicolas Seriot
<
tankf33der>
another now.
<
abu[7]>
I made a stupid erro
<
abu[7]>
replaced map with for
<
tankf33der>
much better.
<
tankf33der>
old code works. array works.
<
abu[7]>
Can you check more? Also the other functions? Then we can release this evening or tomorrow
<
tankf33der>
if that then i must write my own testsuite.
<
tankf33der>
lunch break.
<
abu[7]>
a test suite would be fantastic
<
tankf33der>
But it will test only parser
<
tankf33der>
readJson right?
<
abu[7]>
packJson is analog to printJson
<
tankf33der>
Why two then?
<
tankf33der>
They do different things, right?
<
abu[7]>
pack vs. print
<
tankf33der>
Aaaa, ok
<
tankf33der>
I am hacking from 4am, this is crazy
<
tankf33der>
open this link
<
tankf33der>
you will see json below as example
<
tankf33der>
destinations is array of objects
<
abu[7]>
Later, now in meeting
<
tankf33der>
not 1,2,3 BUT pairs
<
tankf33der>
of course.
<
tankf33der>
testsuite will be here
<
tankf33der>
but first you should not use (quit ...) :)
<
aw->
tankf33der: i should run my parser against those files
<
tankf33der>
perfect
<
aw->
my parser returns NIl if it fails to parse a JSON string (or file)
<
aw->
i wrote a quick script to test each file and i just got a large list of NILs haha
<
aw->
i dunno if that's correct
<
aw->
it doesn't treat a lonely "true" as a valid JSON
<
aw->
even though technically it is
<
aw->
i find it stupid
<
beneroth>
booleans are easy, the hard is the allowed E-notation for numbers (even such which are not valid in Javascript)
<
beneroth>
I guess it is not widely used in practice, but still...
rob_w has quit [Remote host closed the connection]
<
tankf33der>
current json can not create such json: {"mike": [{"1": "2", "2": "2"}, {"1":"2","3":"4"}]}
<
tankf33der>
this can: {"mike": [1, 2]}
ygrek has joined #picolisp
<
abu[7]>
tankf33der, I think 'quit' is needed. Can you 'catch' it?
<
tankf33der>
But i fail on faulty tests
<
abu[7]>
You cat test '@@' after catch
<
abu[7]>
See the 'if2' example in the ref for 'catch'
<
tankf33der>
i do (in "fail.file" (readJson))
<
tankf33der>
right ?
<
tankf33der>
having fun
<
abu[7]>
Instead of (in "file" ..) you can also use 'pipe' or 'input'
<
tankf33der>
catch ok
<
tankf33der>
lets see
<
abu[7]>
: (let S (chop "{a: 1}") (input (++ S) (readJson)))
<
abu[7]>
-> ((a . 1))
<
tankf33der>
if fail file passed is it ok ?
<
abu[7]>
I think this is good. A negative-test.
<
tankf33der>
pass files passed
<
tankf33der>
for one test
<
tankf33der>
doing second
<
abu[7]>
What is your impression? Shall I release it?
<
tankf33der>
you can release it, but i did not get what i really need. see above.
<
tankf33der>
failed, but should somehow pass
<
abu[7]>
Which above?
<
tankf33der>
17:02 <tankf33der> current json can not create such json: {"mike": [{"1": "2", "2": "2"}, {"1":"2","3":"4"}]}
<
tankf33der>
17:03 <tankf33der> this can: {"mike": [1, 2]}
<
abu[7]>
How did you make the second?
<
abu[7]>
(printJson '((mike (T (a . 1)))))
<
abu[7]>
(printJson '((mike (T (a . 1)))))
<
tankf33der>
(printJson
<
tankf33der>
(list 'mike 1 2) ) )
<
tankf33der>
like this
<
tankf33der>
and this code does not work on jsonNEW.l
<
tankf33der>
but jsonNEW passed test suite
<
tankf33der>
no regressions
<
abu[7]>
Hmm, should we redesign the whole lib?
<
tankf33der>
eh. hard decision
<
abu[7]>
Is it only print?
<
abu[7]>
or also read?
<
abu[7]>
(printJson '((mike (a . 1)))) {"mike": {"a": 1}}
<
abu[7]>
(printJson '((mike ((a . 1) (b . 2))))) {"mike": {"(a . 1)": {"b": 2}}}
<
tankf33der>
second is not correct
<
tankf33der>
thats why i always use list or cons
<
tankf33der>
bulletproof
<
abu[7]>
Thats the same
<
tankf33der>
of course, i am a human :)
<
abu[7]>
So let's not release it
<
abu[7]>
I must rethink the whole structure
<
abu[7]>
I don't even know a BNF for Json
<
tankf33der>
there is a picture
<
abu[7]>
ok, I think about it tomorrow
<
abu[7]>
Too bad that this page does not work in a text browser
<
tankf33der>
json BNF in txt