Generated-output differences

quicktype output changed between the PR base and tested PR merge revisions.
← Back to the pull request
1test cases
1files differ
0modified
1new
0deleted
256changed lines
+256 −0insertions / deletions
Base a49b94e8f6f1b319a4da9fb15d57ef13ba316ddc · PR merge 7f7e464ef85e064b369cee9f512e15e86c73a52d · Head f9ea08e0c9e3baca3e420820499b71c42df2bc9e · raw patch
Test case

test/inputs/json/priority/issue-1630

1 generated file · +256 −0
Acsharp-multiple-json-top-levelsdefault / QuickType.cs+256 −0
@@ -0,0 +1,256 @@
1+// <auto-generated />
2+//
3+// To parse this JSON data, add NuGet 'System.Text.Json' then do one of these:
4+//
5+// using QuickType;
6+//
7+// var accountsGetRequest = AccountsGetRequest.FromJson(jsonString);
8+// var authGetRequest = AuthGetRequest.FromJson(jsonString);
9+// var transactionsGetRequest = TransactionsGetRequest.FromJson(jsonString);
10+#nullable enable
11+#pragma warning disable CS8618
12+#pragma warning disable CS8601
13+#pragma warning disable CS8602
14+#pragma warning disable CS8603
15+
16+namespace QuickType
17+{
18+ using System;
19+ using System.Collections.Generic;
20+
21+ using System.Text.Json;
22+ using System.Text.Json.Serialization;
23+ using System.Globalization;
24+
25+ public partial class AccountsGetRequest
26+ {
27+ [JsonRequired]
28+ [JsonPropertyName("access_token")]
29+ public string AccessToken { get; set; }
30+
31+ [JsonRequired]
32+ [JsonPropertyName("client_id")]
33+ public string ClientId { get; set; }
34+
35+ [JsonRequired]
36+ [JsonPropertyName("secret")]
37+ public string Secret { get; set; }
38+ }
39+
40+ public partial class AuthGetRequest
41+ {
42+ [JsonRequired]
43+ [JsonPropertyName("access_token")]
44+ public string AccessToken { get; set; }
45+
46+ [JsonRequired]
47+ [JsonPropertyName("client_id")]
48+ public string ClientId { get; set; }
49+
50+ [JsonRequired]
51+ [JsonPropertyName("options")]
52+ public AuthGetRequestOptions Options { get; set; }
53+
54+ [JsonRequired]
55+ [JsonPropertyName("secret")]
56+ public string Secret { get; set; }
57+ }
58+
59+ public partial class AuthGetRequestOptions
60+ {
61+ [JsonRequired]
62+ [JsonPropertyName("account_ids")]
63+ public string[] AccountIds { get; set; }
64+ }
65+
66+ public partial class TransactionsGetRequest
67+ {
68+ [JsonRequired]
69+ [JsonPropertyName("access_token")]
70+ public string AccessToken { get; set; }
71+
72+ [JsonRequired]
73+ [JsonPropertyName("client_id")]
74+ public string ClientId { get; set; }
75+
76+ [JsonRequired]
77+ [JsonPropertyName("end_date")]
78+ public DateTimeOffset EndDate { get; set; }
79+
80+ [JsonRequired]
81+ [JsonPropertyName("options")]
82+ public TransactionsGetRequestOptions Options { get; set; }
83+
84+ [JsonRequired]
85+ [JsonPropertyName("secret")]
86+ public string Secret { get; set; }
87+
88+ [JsonRequired]
89+ [JsonPropertyName("start_date")]
90+ public DateTimeOffset StartDate { get; set; }
91+ }
92+
93+ public partial class TransactionsGetRequestOptions
94+ {
95+ [JsonRequired]
96+ [JsonPropertyName("account_ids")]
97+ public string[] AccountIds { get; set; }
98+
99+ [JsonRequired]
100+ [JsonPropertyName("count")]
101+ public long Count { get; set; }
102+
103+ [JsonRequired]
104+ [JsonPropertyName("offset")]
105+ public long Offset { get; set; }
106+ }
107+
108+ public partial class AccountsGetRequest
109+ {
110+ public static AccountsGetRequest FromJson(string json) => JsonSerializer.Deserialize<AccountsGetRequest>(json, QuickType.Converter.Settings);
111+ }
112+
113+ public partial class AuthGetRequest
114+ {
115+ public static AuthGetRequest FromJson(string json) => JsonSerializer.Deserialize<AuthGetRequest>(json, QuickType.Converter.Settings);
116+ }
117+
118+ public partial class TransactionsGetRequest
119+ {
120+ public static TransactionsGetRequest FromJson(string json) => JsonSerializer.Deserialize<TransactionsGetRequest>(json, QuickType.Converter.Settings);
121+ }
122+
123+ public static partial class Serialize
124+ {
125+ public static string ToJson(this AccountsGetRequest self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
126+ public static string ToJson(this AuthGetRequest self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
127+ public static string ToJson(this TransactionsGetRequest self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
128+ }
129+
130+ internal static partial class Converter
131+ {
132+ public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
133+ {
134+ Converters =
135+ {
136+ new DateOnlyConverter(),
137+ new TimeOnlyConverter(),
138+ IsoDateTimeOffsetConverter.Singleton
139+ },
140+ };
141+ }
142+
143+ public class DateOnlyConverter : JsonConverter<DateOnly>
144+ {
145+ private readonly string serializationFormat;
146+ public DateOnlyConverter() : this(null) { }
147+
148+ public DateOnlyConverter(string? serializationFormat)
149+ {
150+ this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
151+ }
152+
153+ public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
154+ {
155+ var value = reader.GetString();
156+ return DateOnly.Parse(value!);
157+ }
158+
159+ public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
160+ => writer.WriteStringValue(value.ToString(serializationFormat));
161+ }
162+
163+ public class TimeOnlyConverter : JsonConverter<TimeOnly>
164+ {
165+ private readonly string serializationFormat;
166+
167+ public TimeOnlyConverter() : this(null) { }
168+
169+ public TimeOnlyConverter(string? serializationFormat)
170+ {
171+ this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
172+ }
173+
174+ public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
175+ {
176+ var value = reader.GetString();
177+ return TimeOnly.Parse(value!);
178+ }
179+
180+ public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
181+ => writer.WriteStringValue(value.ToString(serializationFormat));
182+ }
183+
184+ internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
185+ {
186+ public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
187+
188+ private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
189+
190+ private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
191+ private string? _dateTimeFormat;
192+ private CultureInfo? _culture;
193+
194+ public DateTimeStyles DateTimeStyles
195+ {
196+ get => _dateTimeStyles;
197+ set => _dateTimeStyles = value;
198+ }
199+
200+ public string? DateTimeFormat
201+ {
202+ get => _dateTimeFormat ?? string.Empty;
203+ set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
204+ }
205+
206+ public CultureInfo Culture
207+ {
208+ get => _culture ?? CultureInfo.CurrentCulture;
209+ set => _culture = value;
210+ }
211+
212+ public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
213+ {
214+ string text;
215+
216+
217+ if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
218+ || (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
219+ {
220+ value = value.ToUniversalTime();
221+ }
222+
223+ text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
224+
225+ writer.WriteStringValue(text);
226+ }
227+
228+ public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
229+ {
230+ string? dateText = reader.GetString();
231+
232+ if (string.IsNullOrEmpty(dateText) == false)
233+ {
234+ if (!string.IsNullOrEmpty(_dateTimeFormat))
235+ {
236+ return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
237+ }
238+ else
239+ {
240+ return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
241+ }
242+ }
243+ else
244+ {
245+ return default(DateTimeOffset);
246+ }
247+ }
248+
249+
250+ public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
251+ }
252+}
253+#pragma warning restore CS8618
254+#pragma warning restore CS8601
255+#pragma warning restore CS8602
256+#pragma warning restore CS8603
No generated files match these filters.