Open shark8me opened 5 years ago
What do we lose if we only use MemoryAsset/create
with a JSON encoded string metadata?
(^Asset [meta data]
(let [byte-data (to-bytes data)]
(if (string? meta)
(MemoryAsset/create byte-data ^String meta)
(let [^java.util.Map meta-map (stringify-keys meta)]
(MemoryAsset/create byte-data meta-map )))))
So, always use this version (MemoryAsset/create byte-data ^String meta)
instead?
I think it is helpful to do stringify-keys
whenever we pass from Clojure to Java. We probably shouldn't support keyword values.
starfish-java does some default metadata creation if you don't pass an exact String as metadata, which I think is useful.
Thanks @mikera .
We probably shouldn't support keyword values.
Is the current behaviour acceptable then? Starfish Java & Clojure won't handle "bad" metadata; it's a user error if the metadata can't be encoded as JSON.
May we close this issue (if you @mikera agree the current behaviour is correct)?
Yes I think current behaviour is correct. Exceptions should typically be thrown if the user makes an error, so that they know about it an can correct it.
Good to add (negative) tests to verify this of course.
Cool! I will leave this open until I add tests.
Registering an asset with keyword metadata throws a JSON parse exception