public static GdprConsent UnwrapGdprConsent(string json) { GdprConsentWrapper wrapped = JsonSerializer.Deserialize <GdprConsentWrapper>(json); GdprConsent unwrapped = UnwrapGdprConsent(wrapped); return(unwrapped); }
private static GdprConsent UnwrapGdprConsent(GdprConsentWrapper wrapped) { GdprConsent unwrapped = new GdprConsent { uuid = wrapped.uuid, euconsent = wrapped.euconsent, TCData = wrapped.TCData, grants = new Dictionary <string, SpVendorGrant>() }; foreach (KeyValuePair <string, SpVendorGrantWrapper> vendorGrantWrapper in wrapped.grants) { bool isGranted = ((JsonElement)vendorGrantWrapper.Value.vendorGrant).GetBoolean(); Dictionary <string, bool> purposeGrants = new Dictionary <string, bool>(); if (vendorGrantWrapper.Value != null) { foreach (KeyValuePair <string, object> purpGrant in vendorGrantWrapper.Value.purposeGrants) { purposeGrants.Add(purpGrant.Key, ((JsonElement)purpGrant.Value).GetBoolean()); } } unwrapped.grants[vendorGrantWrapper.Key] = new SpVendorGrant(/*isGranted,*/ purposeGrants); } return(unwrapped); }