Skip to content

Add new mapTransform function #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 20, 2021
Merged

Add new mapTransform function #24

merged 3 commits into from
Aug 20, 2021

Conversation

prayansh
Copy link
Contributor

@prayansh prayansh commented Aug 19, 2021

In our efforts to provide convenience APIs, we have added a new function JsonObject.mapTransform(Map<String, String>,((String, JsonElement) -> JsonElement)?) that allows you to easily map keys and transform values based on a closure. Example usage:

 properties.mapTransform(mapOf("x" to "y")) { newKey, value ->
    var newVal = value
    if (newKey == "y") {
        // ... do something
    }
    newVal
}

@prayansh prayansh requested review from wenxi-zeng and migs647 August 20, 2021 00:11
@prayansh prayansh merged commit 6514588 into main Aug 20, 2021
@prayansh prayansh deleted the pray/mapKeys branch August 20, 2021 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants