how to add new property to json?
I have following code:
I need to add following property to each property in
but I don't understand how to do it correctly
var schema = File.ReadAllText("legData.json");
var result = Parse(schema);
Console.WriteLine(result);
string Parse(string jsonSchema)
{
using var document = JsonDocument.Parse(jsonSchema);
var root = document.RootElement;
if(!root.TryGetProperty("properties", out _))
return "";
var properties = root.GetProperty("properties").EnumerateObject();
var property = properties.FirstOrDefault(prop => prop.Value.TryGetProperty("generateModelClassName", out _));
var propertyProperties = property.Value.GetProperty("properties");
var formatted = $$"""{"properties": {{propertyProperties}}}""";
return formatted;
}var schema = File.ReadAllText("legData.json");
var result = Parse(schema);
Console.WriteLine(result);
string Parse(string jsonSchema)
{
using var document = JsonDocument.Parse(jsonSchema);
var root = document.RootElement;
if(!root.TryGetProperty("properties", out _))
return "";
var properties = root.GetProperty("properties").EnumerateObject();
var property = properties.FirstOrDefault(prop => prop.Value.TryGetProperty("generateModelClassName", out _));
var propertyProperties = property.Value.GetProperty("properties");
var formatted = $$"""{"properties": {{propertyProperties}}}""";
return formatted;
}I need to add following property to each property in
propertyPropertiespropertyProperties: "additionalProperties": true"additionalProperties": truebut I don't understand how to do it correctly
