private static JsonSerializerOptions CreateOptions(JsonSerializerOptions options) { options ??= new JsonSerializerOptions(); options.AddJsonApi(); return(options); }
public void Serializing() { var options = new JsonSerializerOptions(); options.AddJsonApi(); for (var i = 0; i < 100000; i++) { JsonSerializer.Serialize(data.Value, data.Type, options); } }
public void Deserializing() { var options = new JsonSerializerOptions(); options.AddJsonApi(); for (var i = 0; i < 100000; i++) { JsonSerializer.Deserialize(data.JsonApiBytes, data.Type, options); } }
public void InsertedResourceConverterIsCalled() { var options = new JsonSerializerOptions(); var converter = new ResourceConverter(); options.AddJsonApi(); options.Converters.Insert(0, converter); Json.Deserialize <Article>(options); Assert.True(converter.ReadCalled); }
public void AppendedResourceConverterNeverCalled() { var options = new JsonSerializerOptions(); var converter = new ResourceConverter(); options.AddJsonApi(); options.Converters.Add(converter); Json.Deserialize <Article>(options); Assert.False(converter.ReadCalled); }
private static JsonSerializerOptions CreateOptions(JsonSerializerOptions options) { options ??= new JsonSerializerOptions(); try { options.WriteIndented = true; options.AddJsonApi(); } catch (InvalidOperationException) { } return(options); }