hankhero / cl-json

Json encoder and decoder for Common-Lisp
Other
75 stars 39 forks source link

Emit an empty array [] #17

Closed ckonstanski closed 7 years ago

ckonstanski commented 7 years ago

Sadly I am working with a REST API that requires the presence of parameters in the JSON even if the value is an empty array []. I am struggling to find a way to get cl-json to emit one of these. '() results in null, '(nil) resuls in [null], etc. Is there a trick for this?

ckonstanski commented 7 years ago

If I change cl-json::json-array-type to something other than LIST, and the new json-arra-type can handle being empty without being confused for nil, is that a valid workaround? Gonna try it though it's going to open a mega can of worms.

ckonstanski commented 7 years ago

I found that simply using an empty vector #() causes cl-json to emit an empty array []. If I'm not imagining things, I think I am good to go.

ckonstanski commented 7 years ago

Verified. Closing.

paulvaneecke commented 4 years ago

Thanks, I was struggling with the same problem!