Gotcha
When working with ujson, it is inevitable, that some string is going to get formatted with line breaks on certain platforms, something like this. ujson mnay crash with a cryptic warning
ujson.read("""
{
"name": "width",
"init": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"on": [
{
"update": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"events": "window:resize"
}
]
}
"""
)
Such problems are infuriatingly hard to debug. The simple solution, is to trim all strings in advance of feeding them to ujson
.
ujson.read("""
{
"name": "width",
"init": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"on": [
{
"update": "isFinite(containerSize()[0]) ? containerSize()[0] : 200",
"events": "window:resize"
}
]
}
""".trim
)
// res0: Value = Obj(
// value = Map(
// "name" -> Str(value = "width"),
// "init" -> Str(value = "isFinite(containerSize()[0]) ? containerSize()[0] : 200"),
// "on" -> Arr(
// value = ArrayBuffer(
// Obj(
// value = Map(
// "update" -> Str(value = "isFinite(containerSize()[0]) ? containerSize()[0] : 200"),
// "events" -> Str(value = "window:resize")
// )
// )
// )
// )
// )
// )