Skip to content
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

Implement addAll functions for JsonArrayBuilder #2156

Merged
merged 15 commits into from May 9, 2023

Conversation

aSemy
Copy link
Contributor

@aSemy aSemy commented Jan 14, 2023

Fix #2127

  • new addAll() method on JsonArrayBuilder
  • new extension functions for adding booleans, numbers, strings - either as a list, or using vararg

Should the new functions be marked with @ExperimentalSerializationApi?

@aSemy aSemy marked this pull request as draft January 14, 2023 22:39
@Goooler
Copy link

Goooler commented Feb 14, 2023

  1. Can we support more Iterable, Sequence, Array as the elements' types like MutableCollection.addAll.
  2. Should we add putAll for JsonObjectBuilder.

Copy link
Member

@sandwwraith sandwwraith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for your PR and sorry it took so long to process it. I think we can accept this functionality after some refining. As you correctly said, all new functions should be marked with @ExperimentalSerializationApi. Can you also please rebase your branch on the latest dev?

*
* @return `true` if the list was changed as the result of the operation.
*/
public fun addAll(elements: Collection<JsonElement>): Boolean =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good this function's signature matches one from MutableList — we can add superclass later without breaking anything 👍🏻

* @return `true` if the list was changed as the result of the operation.
*/
@ExperimentalSerializationApi
public fun JsonArrayBuilder.addAll(vararg elements: JsonElement): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for vararg here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I missed that one. It's now removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also apiDump

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also apiDump

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @sandwwraith, sorry I forgot this! Would you mind updating it? You should have permissions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, no problems

@aSemy aSemy force-pushed the feat/json_array_add_all branch from 50b3420 to dc46b70 Compare May 6, 2023 07:22
* @return `true` if the list was changed as the result of the operation.
*/
@ExperimentalSerializationApi
public fun JsonArrayBuilder.addAll(vararg elements: JsonElement): Boolean {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also apiDump

Copy link
Member

@sandwwraith sandwwraith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you once again!

@sandwwraith sandwwraith merged commit 9157bf8 into Kotlin:dev May 9, 2023
@aSemy aSemy deleted the feat/json_array_add_all branch May 17, 2023 10:28
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.

None yet

3 participants