diff --git a/source/FluentDataBuilder.Yaml/DataBuilderExtensions.cs b/source/FluentDataBuilder.Yaml/DataBuilderExtensions.cs index e246cdc..cc655b0 100644 --- a/source/FluentDataBuilder.Yaml/DataBuilderExtensions.cs +++ b/source/FluentDataBuilder.Yaml/DataBuilderExtensions.cs @@ -20,4 +20,29 @@ public static string Build(this IDataBuilder builder) return yaml; } + + /// + /// Loads data into an IDataBuilder object from a JSON string. + /// + /// The IDataBuilder object to load data into. + /// A JSON string containing the data to load into the IDataBuilder object. + /// The IDataBuilder object with data loaded from the JSON string. + /// + /// This method parses the input JSON string into a JsonDocument and then iterates over the properties of the JsonDocument's root element. + /// For each property, it converts the property into IDataBuilder properties and updates the builder accordingly. + /// + public static IDataBuilder LoadFrom(this IDataBuilder builder, + string yaml) + { + if (string.IsNullOrEmpty(yaml)) + { + return builder; + } + + ar deserializer = new DeserializerBuilder().Build(); + var result = deserializer.Deserialize>(yamlString); + + + return builder; + } } \ No newline at end of file