internal static string MakeJsonData(FullDataSet data) { var w = JWriter.New(); using (var ow = w.Object()) { foreach (var item in data.Items) { if (item.Value.Item != null) { FeatureFlagJsonConverter.WriteJsonValue(item.Value.Item, ow.Name(item.Key)); } } } return(w.GetString()); }
// Currently there is only one serialization schema, but it is possible that future // SDK versions will require a richer model. In that case we will need to design the // serialized format to be distinguishable from previous formats and allow reading // of older formats, while only writing the new format. internal static FullDataSet DeserializeV1Schema(string serializedData) { var builder = ImmutableList.CreateBuilder <KeyValuePair <string, ItemDescriptor> >(); var r = JReader.FromString(serializedData); try { for (var or = r.Object(); or.Next(ref r);) { var flag = FeatureFlagJsonConverter.ReadJsonValue(ref r); builder.Add(new KeyValuePair <string, ItemDescriptor>(or.Name.ToString(), flag.ToItemDescriptor())); } } catch (Exception e) { throw new InvalidDataException(ParseErrorMessage, r.TranslateException(e)); } return(new FullDataSet(builder.ToImmutable())); }