liquidsoap
liquidsoap copied to clipboard
stringify with varying types
The following code
def f(x)
x = x.{a = 3}
let json.stringify s = x
print("JSON: #{s}")
end
f({s="xx"})
f({u=2})
prints
JSON: { "a": 3 }
JSON: { "a": 3 }
Is there a way to print the other fields?...
Found my way with
s = json.stringify(x)
as third line.
I'm reopening, I want to take a minute to look at this. I feel like this might be an issue for others.
I reviewed your code and frankly I'm not sure why I originally thought a json serialization based on the type was a good idea haha. I'll think about it more but otherwise I'm of the opinion to can the let json.stringify
and revert to json.stringify
.