Another question ``` "workItemFields": [ { ...
# serialization
e
Another question
Copy code
"workItemFields": [
    {
      "Microsoft.VSTS.TCM.Steps": ""
    },
    {
      "Microsoft.VSTS.Common.ActivatedBy": "Konan"
    },
    {
      "Microsoft.VSTS.Common.ActivatedDate": "2021-10-19T05:44:38.947Z"
    },
    {
      "Microsoft.VSTS.TCM.AutomationStatus": "Not Automated"
    },
    {
      "System.Description": ""
    },
    {
      "System.State": "Design"
    },
    {
      "System.AssignedTo": "Peter"
    },
    {
      "Microsoft.VSTS.Common.Priority": 1
    },
    {
      "Microsoft.VSTS.Common.StateChangeDate": "2022-08-17T12:25:20.89Z"
    },
    {
      "System.WorkItemType": "Test Case"
    },
    {
      "System.Rev": 40
    }
]
What would be a better way to decoded it comparing to List<Map<String, String>>. At least I don't want to use
isLenient
.
h
I don't understand – why the
List
? It seems to be just a
Map<String, String>
anyway? (i.e. no duplicate keys)
e
[]
is always a list correct?
Copy code
Expected start of the object '{', but had '[' instead at path: $.workItemFields
Looks like correct
h
Yes. So you don't have control over the format…?
e
It is MS Azure output
h
That explains why it's terrible 😄
You might be able do a
List
of `Pair`s instead of having a
Map
for each list entry.
No, probably not 😞
e
Nope, tried it is expecting json like
Copy code
{
  "key": "keyValue",
  "value": "valueValue"
}
h
Yeah, I'm typing faster than I'm thinking.
g
Having an interface + a few implementation each with a @SerialName("System.Rev") could do the trick but eventually it's pretty messy and suppose you know every keys before. When format is too tricky, you can still get a JsonObject and parse it as you wish to fill a clean data structure.
e
Not sure serial name will work
If I'm right it is not key name but additional field
And yeah jsonobject and map are almost same except I can remove lenient necessity
e
you don't need to do anything json-specific. https://pl.kotl.in/oI37sIGY0
e
Thanks!
With this I still need lenient set to true, but I can modify it a bit