How to parse a json node that contains children of different types?
Bagomot
bagomot at gmail.com
Tue Jul 20 21:18:12 UTC 2021
I have a json like this:
```json
{
"arguments":{
"jvm":[
{
"rules":[
{
"action":"allow",
"os":{
"name":"osx"
}
}
],
"value":[
"-XstartOnFirstThread"
]
},
"-Djava.library.path=${natives_directory}"
]
}
}
```
Here the "jvm" node is an array that has different data types for
its elements (json object and string).
I am using [asdf](https://code.dlang.org/packages/asdf) library
to deserialize json. I am trying to deserialize this json into a
structure like this:
```d
struct Arguments{
@serdeKeys("jvm")
Object[] jvm;
}
```
But there is a problem with different types. I understand that
Object[] is not suitable here, but I don’t know how to do it.
I ask you to help me with this.
More information about the Digitalmars-d-learn
mailing list