java - Can not instantiate value of type from json string -


I have bidirectional relationships between users and groups. @

) @ Generated Values ​​(strategy = generation type, sequence, generator = "user_porter") Private Long ID; Private string user name; Private string password; @ManyToMany private list & lt; Groups & gt; group; } @ Entity @Table (name = "GroupTBL") public class group {@Id @SequenceGenerator (name = "group_janerator", serial name = "group_sec", allocation size = 1, initial value = 1) @ generated value (strategy = GenerationType. Sequence, generator = "group_guitar") private long id; The name of the private string; Private string description; @ManyToMany (mapped = "group") private list & lt; Users & gt; Users; }

I am developing an angular JS application with Java jax-rs web service and I'm using Jason Binding on Jackson but I'm getting this exception:

JSON can not instantiate the value of type [ordinary type, class com.blog.models.Group] from string; No single string constructor / factory method (via reference chain: com.blog.models.User ["groups"])

This is sent to my Jason Object server:

  {"groups": ["{\" id \ ": 1, \" name \ ": \" admin \ ", \" description \ ": zero, \" users \ ": []} "," {\ "Id \": 2, \ "name \": \ "user \", \ "description \": null, \ "users \": []} "]," user name ":" Hussien "," password ":" ammar "}  

Resource:

@Stateless @Path (" / user ") Public class UserResource {@ EJB PRIVATE USERS FACED Userfac; @ POST @Consumes (MediaType.APPLICATION_JSON) Public Zero User (user user) {userFacade.create (user); }}

It seems that on behalf of the client, you have twice your JSON object You can string (group) you should call it only once. How is it that the JSON should come in:

  {"groups": [{"id": 1, "name": "admin", "description": null, "users" "Username": "user", "description": blank, "user": []}], "user name": "hussain", "password": "ammar "}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -