Code Monkey home page Code Monkey logo

Comments (2)

FarooqKhan avatar FarooqKhan commented on August 26, 2024

Hi @oiale

Arrays.asList("A", "B") returns a object of type Arrays$ArrayList```

Arrays.asList returns a List implementation, but it's not a java.util.ArrayList. It happens to have a classname of ArrayList, but that's a nested class within Arrays - a completely different type from java.util.ArrayList

Also JsonDB uses XMLEncoder internally to create a deep copy of objects before processing them. However Arrays$ArrayList does not serialise properly, thats probably because XMLEncoder requires it to be a valid JavaBean, meaning among other things it should have a default public constructor which Arrays does not have

So the way you are using it, its not going to work. To workaround this issue I suggest you create a proper java.util.List and then set it into the bean:

List<String> stuff = new ArrayList<String>(Arrays.asList("A", "B"));
bean.setStuff(stuff);

This should work, i added a unit test to test this and it passes just fine.

The latest build on Maven Central is: 1.0.64

from jsondb-core.

 avatar commented on August 26, 2024

@FarooqKhan
Thank you, the issue is resolved. Do you have a wiki that you could put this on?

from jsondb-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.