public SoftwareStatementPayload SoftwareStatementPayloadFromBase64(string payloadBase64) { // Perform conversion string payloadString = Base64UrlEncoder.Decode(payloadBase64); SoftwareStatementPayload newObject = JsonConvert.DeserializeObject <SoftwareStatementPayload>(payloadString); // Check reverse conversion works or throw // (If reverse conversion fails, we can never re-generate base64 correctly) // if (payloadBase64 != SoftwareStatementPayloadToBase64(newObject)) // { // throw new ArgumentException("Please update SoftwareStatementPayload type to support your software statement"); // } return(newObject); }
public string SoftwareStatementPayloadToBase64(SoftwareStatementPayload payload) { string jsonData = JsonConvert.SerializeObject(payload); return(Base64UrlEncoder.Encode(jsonData)); }