typing complex json literals in carp is annoying.
(defn empty-provision []
(JSON.obj [(JSON.entry @"created_fields" (JSON.Arr (the (Array (Box JSON)) [])))
(JSON.entry @"created_tags" (JSON.Arr (the (Array (Box JSON)) [])))]))
but the alternative requires a parse.
(defn empty-provision []
(Result.unsafe-from-success (JSON.parse "{\"created_fields\": [], \"created_tags\": []}")))
which is equally annoying. i’d prefer being able to offload this to compile time, and adding a macro that compiles json literals into a carp expression.
; name tbd
(macro-expand (JSON.literal "{\"created_fields\": [], \"created_tags\": []}")))
; expands to
; (JSON.obj [(JSON.entry @"created_fields" (JSON.Arr (the (Array (Box JSON)) [])))
; (JSON.entry @"created_tags" (JSON.Arr (the (Array (Box JSON)) [])))]))
nice error checking and good output would be table stakes here.
cheers
typing complex json literals in carp is annoying.
but the alternative requires a parse.
which is equally annoying. i’d prefer being able to offload this to compile time, and adding a macro that compiles json literals into a carp expression.
nice error checking and good output would be table stakes here.
cheers