How can i rename a field using mapneat, wich is inside list object #27
Answered
by
nomemory
hudavianto92
asked this question in
Q&A
-
How can i rename a field using mapneat, wich is inside list object like this
into this
i try to transform it like this, but doesn't work
|
Beta Was this translation helpful? Give feedback.
Answered by
nomemory
Oct 20, 2021
Replies: 1 comment
-
The code that is performing what you are looking for: val source = """
{
"detail" : [
{
"name" : "huda"
},
{
"name" : "syahnaz"
}
]
}
"""
fun main() {
var value = json(fromJson(source)) {
"detail" *= "$.detail"
val detail = getObjectMap().get("detail") as List<Object>
"detil" /= detail.map {
json(fromObject(it)) {
"nama" *= "$.name"
}
}.toList()
- "detail"
}.getPrettyString()
print(value)
} Output:
Hope it helps. The main idea is to:
Hope it helps |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hudavianto92
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hudavianto92
The code that is performing what you are looking for:
Output:
Hope it helps.
The main idea i…