- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to convert a JSON response to a list which I can then manipulate with AutoLISP.
Normally I can accomplish that with this simple function:
(defun JSON->LIST (json / tmp dbl nwl) ;json - string, as json data ;returns - list or nil, list of data converted from json (if (eq 'STR (type json)) (read (vl-string-translate "[]{}:," "()() " json)) nil) );defun
However, the READ function must have a limit which I cannot directly find. Because when I send the Attached JSON information as a single string to the function, I get this error:
; error: string too long on input
I have tried removing excess spaces and newline characters with:
- (while (vl-string-search " " str) (setq str (vl-string-subst " " " ")))
- (while (vl-string-search "\n" str) (setq str (vl-string-subst " " "\n")))
Still no luck. (my shortened string length comes to 37,367 characters).
So, I was hoping that I could create any function (perhaps recursive?) that will allow me to merely construct lists on the fly since, in THIS case, I know that I have many 'Lists' inside of my JSON data. Then I could break my 'Reads' into smaller chunks... I just am not able to understand how my workflow should go and I have been racking my brain on this for hours..
This isn't a function but hopefully it can help you get an idea of how i'm trying to break this down:
Instead of this: (read "(\"abc\" 123 (\"def\" 456) (\"ghi\" 789) \"jkl\" 000)") ...Do this... (list "abc" 123 (list "def" 456) (list "ghi" 789) "jkl" 000)
Best,
~DD
Solved! Go to Solution.