Open si14 opened 10 years ago
From the README: "Note that this is a plain JavaScript library, so if you want to pass options make sure you first coerce them to a JavaScript object".
I think the issue is that you are passing the jtl/serialize
function a ClojureScript map when it is expecting a JavaScript object.
See the last paragraph of the "Usage" section of the README---the serialize fn actually accepts a goog Closure map instance.
Here is a minimal example with goog.structs/Map:
(defrecord Testrec [foo])
(defn ^:export test3 []
(let [cons-table {Testrec (fn [x]
(.log js/console "serialization reached")
["repository" (clj->js x)])}
cons-table (goog.structs/Map. (clj->js cons-table))
arg (clj->js {"constructor_table", cons-table})]
(jtl/serialize (Testrec. "bar") arg)))
It fails with RangeError: Maximum call stack size exceeded
without ever calling serialization function. Does it really an intended behavior even if something is wrong with constructor_table
? Can you please provide an example of working serialization with record?
I can be missing something, but I always get
RangeError: Maximum call stack size exceeded
when I runtest2
from the following code (test1
works fine):Is it OK? When I add debug output to the function inside constructor table I don't get an output from it. What exactly should be provided as a key in that map?