JsonObject item back to List<Object>


i have problems with serializing and deseralizing back to my class.

Convert JsonObject back to ob

I have a collection like this IReadOnlyCollection<CompanyCustomer>

 public class CompanyCustomer
    public Guid? CompanyId { get; set; }
    public Guid? CustomerId { get; set; }

This works fine to serialize into json



I then save it into a JSONObject (my JWTToken)

string jsonString = jsonSerialiser.Serialize(membershipSession.CompanyCustomers);
token.Add("CompanyCustomers", jsonString);

But when i try to deserialize it back it get an error

membershipSession.CompanyCustomers = jsonSerialiser.Deserialize<IReadOnlyCollection<CompanyCustomer>>(token["CompanyCustomers"]);

Invalid JSON primitive: 00000000-0000-0000-0000-000000000000.

Please help

I don’t think you’re using ServiceStack classes as we don’t have a JsonObject that has Serialize and Deserialize APIs on it.

Hi mythz,

thx for your reply.
Ok, if I change my question. How can i save an list of a class with guids into the JWT Token and then read that token again.
I’m tried with serialize and deserialize into json but it doesnt work.

Please guide me.

Regards Kristian

You can use the CreateJwt* APIs on JwtAuthProvider to manually create JWTs as seen in the example in the docs.

The APIs allow you to easily convert a ServiceStack UserSession to a JWT and vice-versa, but they’re not a general purpose API for creating JWTs.

i solved it using

token.GetUnescaped() instead of token.Get



Regards Kristian