I'm using json4s library in my project to manually parse JSON field by field (without automatic deserializing it to case classes).
For example I have following JSON:
{
result: "OK",
persons: [
{name: "Alex"},
{name: null}
]
}
And the official guide suggest to use this approach to manually parse it:
for {
JArray(persons) <- json / "persons"
JObject(person) <- persons
JField("name", JString(name)) <- person
} yield Person(name)
The problem is that this for-comprehension skips persons which has null names. I think this is because in for-comprehension I used JString(name), so it expects some String value, not a null.
Is there any way to solve this? I just want to iterate over array and visit every object (even if it has null instead some String)