/// <summary> /// Unmarshals a feature store item from a JSON string. This is a convenience method for /// feature store implementations, so that they can use the same JSON library that is used /// within the LaunchDarkly SDK rather than importing one themselves. All of the storeable /// classes used by the SDK are guaranteed to support this type of deserialization. /// /// This is the same as the other UnmarshalJson method, except that it returns an /// <see cref="IVersionedData"/> rather than a more specific type. This is more likely /// to be useful if you are implementing <see cref="IFeatureStoreCore"/>. /// </summary> /// <param name="kind">specifies the type of item being decoded</param> /// <param name="data">the JSON string</param> /// <returns>the unmarshaled item</returns> /// <exception cref="UnmarshalException">if the string format is invalid</exception> public static IVersionedData UnmarshalJson(IVersionedDataKind kind, string data) { try { return((IVersionedData)JsonConvert.DeserializeObject(data, kind.GetItemType())); } catch (JsonException e) { throw new UnmarshalException("Unable to unmarshal " + kind.GetItemType().Name, e); } }
/// <summary> /// Unmarshals a feature store item from a JSON string. This is a convenience method for /// feature store implementations, so that they can use the same JSON library that is used /// within the LaunchDarkly SDK rather than importing one themselves. All of the storeable /// classes used by the SDK are guaranteed to support this type of deserialization. /// /// This is the same as the other UnmarshalJson method, except that it returns an /// <see cref="IVersionedData"/> rather than a more specific type. This is more likely /// to be useful if you are implementing <see cref="IFeatureStoreCore"/>. /// </summary> /// <param name="kind">specifies the type of item being decoded</param> /// <param name="data">the JSON string</param> /// <returns>the unmarshaled item</returns> /// <exception cref="UnmarshalException">if the string format is invalid</exception> public static IVersionedData UnmarshalJson(IVersionedDataKind kind, string data) { try { return((IVersionedData)JsonUtil.DecodeJson(data, kind.GetItemType())); } catch (JsonException e) { throw new UnmarshalException("Unable to unmarshal " + kind.GetItemType().Name, e); } }