返された JSON は、入力した DTO の形状 (つまり、最初の DTO の役割) と正確に一致します。したがって、DTO を変更して、必要な正確な形状を表す必要があります。
public class TestResponse {
public TestRoot Root { get; set; }
}
public class TestRoot {
public string Name { get; set; }
}
その後、期待どおりに返すことができます。
return new TestResponse { Root = new TestRoot { Name = "Value" } };
または、必要に応じて、辞書を使用することもできます。
public class TestResponse {
public TestResponse() {
this.Root = new Dictionary<string,string>();
}
public Dictionary<string,string> Root { get; set; }
}
そしてそれを返します:
return new TestResponse { Root = { { "Name", "Value" } } };