Reputation: 388
I have a list of documents, with data in the form of Map[String, Any]
so that it can be added to a json object with fields and values respectively. So my code looks something like this when parsing:
val JsonDoc = Json.obj(
"ORFID" -> doc("ORFID").toString,
"ORF_len" -> doc("ORF_len").toString,
"start" -> doc("start").toString,
"end" -> doc("end").toString
...// more fields
)
However some documents may be missing one of the fields, so I need a more dynamic approach depending on each documents fields, or else an exception is thrown. What would be the best approach for this?
Upvotes: 0
Views: 185