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

marshalling defined for class should also work with collection of that class by only defining the annotation #28

Closed
GoogleCodeExporter opened this issue May 2, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Entity:

@Entity
public class Complex {
  @Value(type = com.twolattes.json.types.URLType.class)
  public List<URL> urlList;

  public static void main(String args[]) {
    try{
    Complex c = new Complex();
    c.urlList = new ArrayList<URL>();
    c.urlList.add(new URL("http","www.google.com",8080,""));
    c.urlList.add(new URL("http","www.yahoo.com",8080,""));   

    Marshaller<Complex> m = TwoLattes.createMarshaller(Complex.class);
    Json.Object obj = m.marshall(c);
    System.out.println(obj);
    }
    catch(Exception ex)
    {
      System.out.println(ex.getMessage());
    }
  }
}

JSON:

What is the expected output? What do you see instead?
expected output:
{"urlList":["http://www.google.com:8080","http://www.yahoo.com:8080"]}

I see null, and the exception is mentioned below.

Please provide any additional information below.
I am having the following exception right now:
java.lang.ClassCastException

Original issue reported on code.google.com by nabil.sh...@gmail.com on 24 Dec 2009 at 5:11

@GoogleCodeExporter
Copy link
Author

You'll want to do

TwoLattes.withType(URLType.class).createMarshaller(Complex.class);

to make this example work. This is the intended behaviour.

Original comment by pascallo...@gmail.com on 24 Dec 2009 at 6:10

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

Issue 29 has been merged into this issue.

Original comment by pascallo...@gmail.com on 6 Jan 2010 at 7:46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant