fastjson Anyway to get FastJson object parser running with dependency injector like guice?

g52tjvyc  于 2021-11-27  发布在  Java
关注(0)|答案(2)|浏览(306)

Suppose my bean that needs to be marshalled from a JSON string is:

public class Foo {
   private Dao dao
   private String id;
   private int n;
   // other fields...

   @Inject
   public Foo(Dao dao) {
      this.dao = dao;
   }

   public void setId(String id) {this.id = id;}
   // other setters ... 
}

If I run JSON.parseObject(input, Foo.class) I will get an error says: default constructor not found.

I would like to know if there are any way to let FastJson able to work with Guice and have Guice to provide the bean instance before setting properties from the JSON string input.

1tu0hz3e

1tu0hz3e1#

it can not support, because it may be a security problem

wixjitnu

wixjitnu2#

How come? Can you please elaborate?

相关问题