Add fromJson function and test deserialization