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

JS Array inside Struct don't set the value inside of the otto.VM #386

Closed
gus2286 opened this issue Aug 5, 2020 · 0 comments · Fixed by #454
Closed

JS Array inside Struct don't set the value inside of the otto.VM #386

gus2286 opened this issue Aug 5, 2020 · 0 comments · Fixed by #454

Comments

@gus2286
Copy link

gus2286 commented Aug 5, 2020

Hello,

I'm want to say thank you to all of you for making this package, I love it.

I want to ask if you can help me to see what I'm doing wrong with this:

I have a struct with array:

type MessageType struct {
	TypeMessage		string			`json:"TypeMessage"`
	Field			[130]string        	`json:"Field"`
}

var MsgOUT MessageType

After that I set the value to be used on the VM:

vm := otto.New()
errSet := vm.Set("MSG_OUT", &MsgOUT)

JS code:

MSG_OUT.TypeMessage = 'something';
MSG_OUT.Field[1] = '60';
MSG_OUT.Field[2] = 'PEPE';

If I make a console.log inside the JS the 'MSG_OUT.TypeMessage' is correct seted, but the array doesn't is still empty 'MSG_OUT.Field[1]'.

What I'm doing wrong?

Thank you very much
Cheers

stevenh added a commit that referenced this issue Nov 26, 2022
Fix array writes not being persisted by passing in writeable
reflect.Value when available instead of .Interface() which looses that
property.

Also:
* Correct typo of writeable.
* Use value.IsValid() instead of comparison with zero entry.

Fixes #386
stevenh added a commit that referenced this issue Nov 26, 2022
Fix array writes not being persisted by passing in writeable
reflect.Value when available instead of .Interface() which looses that
property.

Also:
* Correct typo of writeable.
* Use value.IsValid() instead of comparison with zero entry.

Fixes #386
stevenh added a commit that referenced this issue Nov 26, 2022
Fix array writes not being persisted by passing in writeable
reflect.Value when available instead of .Interface() which looses that
property.

Also:
* Use value.IsValid() instead of comparison with zero entry.
* Use propertyLength instead of literal.

Fixes #386
stevenh added a commit that referenced this issue Nov 26, 2022
Fix array writes not being persisted by passing in writeable
reflect.Value when available instead of .Interface() which looses that
property.

Also:
* Use value.IsValid() instead of comparison with zero entry.
* Use propertyLength instead of literal.

Fixes #386
sg3des pushed a commit to sg3des/otto that referenced this issue Jul 17, 2023
Fix array writes not being persisted by passing in writeable
reflect.Value when available instead of .Interface() which looses that
property.

Also:
* Use value.IsValid() instead of comparison with zero entry.
* Use propertyLength instead of literal.

Fixes robertkrimen#386
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 a pull request may close this issue.

1 participant