Home  >  Q&A  >  body text

java-web - JAVA语言如何实现ES6 Object.assign,两个属性相同的对象增量更新字段信息,最好最快的实现方式?

对象比较复杂,对象拥有其他对象,最好的实现方式是什么

PHP中文网PHP中文网2741 days ago931

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-18 10:55:06

    Java is not as convenient as js to get attribute fields. You have to use reflection

    There is no other way to obtain the properties and values ​​​​of two objects through reflection and then traverse

    A convenient way is to convert the object into a map, then traverse the attributes, and finally convert the map back to the object. This process can be done with json-related tools such as gson or fastjson

    reply
    0
  • Cancelreply