JSON is created in Java using Jersey's JAXB serializer. I need to deserialize it in .NET application. The problem is in serialized arrays: if array contains several items JSON object is like that:
{"users":[{"name":"user1", "email":"user1@email.com"},{"name":"user2", "email":"user2@email.com"}]}
but when object contains only one item it is serialized as a simple object
{"users":{"name":"user1", "email":"user1@email.com"}}
I want to deserialize it into .NET object.
public class UserList{
public List<User> users {get;set;}
}
public class User{
public string name {get;set;}
public string email {get;set;}
}
Standard .NET deserializer does not understand the second case. I tried JSON.NET default deserializer but it throws exception. Maybe it needs to be configured properly?.. Can you suggest something how to deal with first and second cases. P.S. I have no access to the Java serializer