Skip to content

V8ObjectUtils.setValue method supports array values#616

Open
Kathircpe wants to merge 1 commit into
eclipsesource:masterfrom
Kathircpe:fix/V8ObjectUtils.setValue-support-array-value
Open

V8ObjectUtils.setValue method supports array values#616
Kathircpe wants to merge 1 commit into
eclipsesource:masterfrom
Kathircpe:fix/V8ObjectUtils.setValue-support-array-value

Conversation

@Kathircpe

Copy link
Copy Markdown

What does this PR do?

This change adds proper support for arrays when calling
V8ObjectUtils.setValue with minimal change in the existing code.

How is it fixed?

A new toList has been created instead of using Arrays.asList(array) method in order to convert the array into a list to
pass it to toV8Array method.

Why not the Arrays.asList() method?

Primitive arrays will wrapped as a single element due to
Arrays.asList varargs behavior, resulting in nested output.
The implementation now converts arrays using java.lang.reflect.Array
before delegating to the existing list-processing logic. This ensures both
object arrays and primitive arrays are flattened correctly.

Why is this needed?

Arrays.asList() treats primitive arrays as a single element, which caused
extra nesting layers in the resulting V8Array.

Related issue

Fixes #24

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.

V8ObjectUtils.setValue should support Array values

1 participant