I've spent too much time trying to make this work, I'm new to Scala.
Basically I make a request to an API and get the following response:
[
{
"id": "bde585ea-43ad-4e62-9f20-ea721193e0a5",
"clientId": "account",
"realm":"test-realm-uqrw"
"name": "${client_account}",
"rootUrl": "${authBaseUrl}",
"baseUrl": "/realms/test-realm-uqrw/account/",
"surrogateAuthRequired": false,
"enabled": true,
"alwaysDisplayInConsole": false,
"clientAuthenticatorType": "client-secret",
"defaultRoles": [
"manage-account",
"view-profile"
],
"redirectUris": [
"/realms/test-realm-uqrw/account/*"
],
"webOrigins": [],
"protocol": "openid-connect",
"attributes": {},
"authenticationFlowBindingOverrides": {},
"fullScopeAllowed": false,
"nodeReRegistrationTimeout": 0,
"defaultClientScopes": [
"web-origins",
"role_list",
],
"access": {
"view": true,
"configure": true,
"manage": true
}
},
{..another object of the same type, different values },
{..another object of the same type, different values }
]
I just need to extract the "id" field from any of those objects(I match by the realm attribute later on). Is there a simple way to convert that json list into a List[] of Map[String, Any]? I say Any because the type of values are so varied - booleans, strings, maps, lists.
I've tried a couple of methods (internal tools) and Jackson(error: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of scala.collection.immutable.List(no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information) and the closest I got was to a weird list of Tuples giving me the incorrect result (because of incorrect processing).
What is a simple way to do this? Or am I destined to create a custom class for this API response? Or can I just walk down this JSON document (I just want one value from one of the objects in that array) and extract the value?