I have a JSON object and part of it I am mapping to AnyRef due to the fact that it might contain the variable key/value pairs. I treat that section as junk drawer. But I have to add "id" and random key to that AnyRef object. How can I do that?
I have tried to do the following but the map is stored and the generated JSON does not look right.
Here is my example:
val map1 = requestStateChange.cloudModel.asInstanceOf[Option[Map[String, AnyRef]]]
val newModel = List(("id", java.util.UUID.randomUUID().toString)).toMap[String, AnyRef] ++ map1.get
What I really want to have generates is something like this:
{
"model": {
"id": "c9725317-e2e5-43e8-876e-5ab6a16b951d"
"version": "v1",
"location": "...",
"type": "...",
"data": {
"id": "9520146"
}
}
}
Appreciate for your help.