I am interpreting some data that is coming through an input that has ; in it specifically “M-F 8am – 8pm; Sat-Sum 9am-10pm” which is cutting off my JSON and making my object break. What ways can I get around this??
{"id":null,"initPath":"/home","storeLocator":{"queryString":"edina"},"order":{"Store_ID":"10305","Store_Info":"7700 NORMANDALE BLVD, EDINA, MN, 55439","Hours_Of_Operation":"M-F 8am - 8pm; Sat-Sum 9am-10pm","Store_Phone":"111-222-3333","Language_ID":"4"},"orderLabel":{"Order_Summary":"Order Summary","Location":"Pick Up Location:","Hours":"Store Hours:","OC_Participation_Level_Description":"Participation Level:","OC_Type_Name":"Cake Type:","OC_Cake_Design_ID":"Design:","Shape":"Shape:","Size":"Size:","Serves":"Serves:","Price":"Price:","Tax":"Tax:","Total":"Total:","Top_Border_Icing_Color_ID":"Top Border:","Bottom_Border_Icing_Color_ID":"Bottom Border:","Decoration_Comment":"Decoration Comment:","Special_Request_Comment":"Special Request:","Personalization":"Message:","Personalization_Color_ID":"Message Color:","Upload_Image_Filename":"Upload Image:","Quantity":"Quantity:","OC_Salutation_ID":"Message:","Special_Occasion_Comment":"Comments:","Customer_First_Name":"First Name:","Customer_Last_Name":"Last Name:","Pickup_Date":"Pick Up Date:","Phone_No":"Phone Number:","Email_Address":"Email Address:","IP_Address":"IP Address:","Ordering_Device":"Ordering Device:","Ordering_OS":"Ordering OS:","Ordering_Browser":"Ordering Browser:","Store_id":"Store:","Language_id":"Language:","OC_Shape_Size_ID":"Shape Size","Back_Button":"Back","Place_Order_Button":"Place Order","Pickup_Time":"Pick Up Time:","Lead_Time":"Lead Time:","Days":"days","Image":"Image:"},"choices":{},"countryId":"US","languageId":"4"}
I am then storing this in a cookie which then parses it back as this when getting it back
{"id":null,"initPath":"/home","storeLocator":{"queryString":"edina"},"order":{"Store_ID":"10305","Store_Info":"7700 NORMANDALE BLVD, EDINA, MN, 55439","Hours_Of_Operation":"M-F 8am - 8pm
I am saving the JSON in a cookie with this command
session = $.JSON.encode(session);
document.cookie = "dqcakes_session=" + encodeURIComponent(session) + "; path=/";
and decoding with this
var session = getCookie("dqcakes_session");
session = $.JSON.decode(decodeURIComponent(session));
Could this possibly be the encodeURIComponent??
I’m just using a simple parser for the JSON and it can’t be that.
Try url encoding the json string before placing it in the cookie.
replacing it with ‘%3b’ manually may work also.