JSON values aren't decomposed in JSON dictionary literals
WilsonGramer opened this issue · comments
Wilson Gramer commented
Composing a dictionary literal with JSON properties results in those properties being null, instead of decomposing them into dictionaries themselves. For example, when
let foo = ["foo": 3] as JSON
let bar = ["bar": foo] as JSON
bar
should equal
[
"foo": [
"bar": 3
]
] as JSON
However, bar
actually equals
[
"foo": JSON.null
] as JSON
To fix this issue, the JSON.init(_ object: Any)
initializer should set self
to object
when object
is an instance of JSON
. I'll submit a PR for this later today; let me know what you think!
Saoud Rizwan commented
Thanks for pointing this out. I just pushed a fix in version 2.0.2