Skip to content

Remove the map function on JsonNode #5932

@cjdxhjj

Description

@cjdxhjj

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

Image The new version has added a map function to JsonNode for transforming JsonNode. I frequently use Kotlin, and since JsonNode implements Iterable, I could conveniently use node.map { it.xx } for a JsonArray to process each JsonNode and obtain a List. However, the newly added map function has overridden the map operator from Iterable with the one defined on JsonNode itself. As a result, I have to use much more verbose syntax, such as:
private fun <T> JsonNode.mapArray(fn: (JsonNode) -> T): List<T> = IntRange(0, size() - 1).map { fn(get(it)) }

I then renamed it to mapArr to avoid conflicts. While the native map operator on JsonNode has some use cases, I believe it is far less functional and practical than the map operator from Iterable.

When I upgrade to the new version, I have to adjust my original code.

Version Information

3.1.0

Reproduction

<-- Any of the following

  1. Brief code sample/snippet: include here in preformatted/code section
  2. Longer example stored somewhere else (diff repo, snippet), add a link
  3. Textual explanation: include here
    -->
// Your code here

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    will-not-fixClosed as either non-issue or something not planned to be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions