Add json serialization

Need to test it.
Characters will be serialized now.