Hello jcubic,
Thanks for your input. It feels like it is converting the list to a js-object when being output as a plain list.
I have come up with a function json->list that restores the list back to its original state.
(define (json->list jinput)
(if (or (js-null? (js-ref jinput "car"))
(js-undefined? (js-ref jinput "car")))
(if (or (number? jinput)
(string? jinput))
jinput ;; primitive
'()) ;; empty object
;; lets assume that car means cdr is also present
(cons (json->list (js-ref jinput "car"))
(json->list (js-ref jinput "cdr")))))
This works for simple case below but is probably complete for all complex cases.
(define jsonobj (js-invoke (js-eval "JSON") "parse"
"{\"car\":{\"car\":\"home\",\"cdr\":{\"car\":23, \"cdr\":{}}},
\"cdr\":{\"car\":{\"car\":\"meow\",\"cdr\":{}},\"cdr\":{\"car\":\"travel\",\"cdr\":{\"car\":\"dev\",\"cdr\":{}}}}}"))
(console-log (json->list jsonobj))
;; (("home" 23) ("meow") "travel" "dev")
Regards,
Alok