I have a site cookie where the value is a JSON object. I serialize this to a specific type in my server code and back to JSON when passing back as a cookie. Everything works fine but now i need to write to the cookie in javascript.
The problem i am having is JSON.stringify is URLEncoding the RAW value which is causing an "Invalid JSON primitive" when calling JavascriptSerializer.Deserialize on the server side. It does not know how to handle the URLEncoding.
I'd much rather get this figured out on the client side because all existing users have cookies that are NOT urlencoded.
I need a JS JSON serializer that does not URLencode!
RAW data looks like:
%7B%0A%20%20%22ClientGuid%22%3A%20%222bb1c08a-0813-4739-8f09-9e9576e6f626%22%2C%0A%20%20%22UserId%22%3A%203601%2C%0A%20%20%22OrganizationId%22%3A%20null%2C%0A%20%20%22OrganizationName%22%3A%20null%2C%0A%20%20%22CampaignId%22%3A%2087%2C%0A%20%20%22EmailAddress%22%3A%20null%2C%0A%20%20%22LastCommodityId%22%3A%20157%2C%0A%20%20%22LastRegionId%22%3A%201%2C%0A%20%20%22LastCategoryId%22%3A%205%2C%0A%20%20%22LastSpmId%22%3A%200%2C%0A%20%20%22LastSpmCategoryId%22%3A%200%2C%0A%20%20%22ShowDetailsAllCommodities%22%3A%20false%0A%7D
should look like:
{ "ClientGuid": "2bb1c08a-0813-4739-8f09-9e9576e6f626", "UserId": 3601, "OrganizationId": null, "OrganizationName": null, "CampaignId": 87, "EmailAddress": null, "LastCommodityId": 157, "LastRegionId": 1, "LastCategoryId": 5, "LastSpmId": 0, "LastSpmCategoryId": 0, "ShowDetailsAllCommodities": false }