public void WriteReason(EvaluationReason?reason) { if (reason.HasValue) { EvaluationReasonConverter.WriteJsonValue(reason.Value, _obj.Name("reason")); } }
public void WriteJson(object value, IValueWriter writer) { var state = value as FeatureFlagsState; if (state is null) { writer.Null(); return; } var obj = writer.Object(); foreach (var entry in state._flags) { LdValueConverter.WriteJsonValue(entry.Value.Value, obj.Name(entry.Key)); } obj.Name("$valid").Bool(state._valid); var allMetadataObj = obj.Name("$flagsState").Object(); foreach (var entry in state._flags) { var flagMetadataObj = allMetadataObj.Name(entry.Key).Object(); var meta = entry.Value; flagMetadataObj.Name("variation").IntOrNull(meta.Variation); flagMetadataObj.Name("version").IntOrNull(meta.Version); flagMetadataObj.MaybeName("trackEvents", meta.TrackEvents).Bool(meta.TrackEvents); flagMetadataObj.MaybeName("debugEventsUntilDate", meta.DebugEventsUntilDate.HasValue) .Long(meta.DebugEventsUntilDate?.Value ?? 0); if (meta.Reason.HasValue) { EvaluationReasonConverter.WriteJsonValue(meta.Reason.Value, flagMetadataObj.Name("reason")); } flagMetadataObj.End(); } allMetadataObj.End(); obj.End(); }