Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm writing a GWT application and I need to pass an array of java objects into JavaScript (or convert such array to JS array), I'm very new to JSNI and wondering if it's possible to do. For example :

public class EntityBase {

    private String id;

    private String name;

    public EntityBase(int id) {
        this.id = id;
    }
}

and I have an array of such objects...can I pass them correctly? If not, what will you suggest me to do? Thanks for any help.

share|improve this question

2 Answers

up vote 2 down vote accepted

You can use GSON to encode and decode objects.

As alternative, you can use AutoBeans.

I use AutoBean, but GSON may have less overhead for you. You may need to add a Default Constructor (without parameter) and get/set Methods.

share|improve this answer
Thanks for advice to use GSON, it was exactly what I was looking for – Arsen Salamakha Jan 23 at 7:21
1  
So click at "accept answer" – Christian Kuetbach Jan 23 at 8:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.