Giter Site home page Giter Site logo

Comments (3)

berkesa avatar berkesa commented on June 3, 2024

Hi @mastermind1981!

What do you mean by complex type? Java Beans with getter and setter methods? If so, it is not possible to dynamically modify its content (can only be used for generating JSONs with Jackson API). The Tree API designed for working with Collections.

Tree API doesn't use reflection for speed and simplicity, only works with collection classes (Map, List, Array) and generic data types. These generic types are: numbers (int, float, short, double, BigDecimal, BigInteger, byte, long), String, Date, InetAddress, UUID, Boolean and byte array.

If you want to put Java Beans into a Tree, convert them into a simple, hierarchical collection-based structure. For this purpose (to convert POJO to Map), use the ObjectMapper class. The Map created with the ObjectMapper can be wrapped with a Tree object:

ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
Map<String, Object> map = objectMapper.convertValue(pojo, Map.class);
Tree tree = new Tree(map);
tree.put("kycScoreResponse._return.resultDatas[0].actions.type", "value");

from datatree.

mastermind1981 avatar mastermind1981 commented on June 3, 2024

@berkesa thanks ... In fact, I was abusing the API a little ... my goal was to generate a properties file by constructing a Tree representing a class hierarchy with default values for the fields and storing the constructed Tree as Properties ... it worked except in the scenario described in my message

from datatree.

berkesa avatar berkesa commented on June 3, 2024

Ok, I understand. With the method above you can save POJO objects in the following formats:

  • JSON (human-readable)
  • YAML (human-readable)
  • TOML (human-readable)
  • SMILE (binary)
  • BSON (binary)
  • CBOR (binary)

from datatree.

Related Issues (2)

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.