Questions tagged [utf8json]

Use this tag for question specifically about the Utf8Json library, a pretty Fast JSON Serializer for C#

As it's github's README says:

Definitely Fastest and Zero Allocation JSON Serializer for C#(.NET, .NET Core, Unity and Xamarin), this serializer write/read directly to UTF8 binary so boostup performance.

See the github page for benchmarks and usage guidance.

19 questions
4
votes
1 answer

I set default JsonSerializer to Utf8Json

Using c# 8 and .netcore 3.1. I've read HERE that Utf8Json library process json serialization and deserialization faster that NewtonsoftJson. We've recently upgraded our servers code from .netcore 2.2 to 3.1 mostly for performance improvements. Thus,…
Ori Refael
  • 2,888
  • 3
  • 37
  • 68
2
votes
1 answer

Make properties case insensitive

EDIT: I am using Utf8Json not System.Text.Json Is there any possible way to make Utf8Json Deserializer case insensitive? Currently if json key-case doesn't match property-case then values are not populated. I don't want to use [DataMember(Name…
Danial Ahmed
  • 856
  • 1
  • 10
  • 26
2
votes
1 answer

Exclude null fields while serialization using Utf8Json library?

Is there any way to ignore null fields while serializing POCO to JSON string using Utf8Json library? I have a ToString method in my below class which I am using externally so I wanted to see if there is any way to exclude null fields while doing…
AndyP
  • 527
  • 1
  • 14
  • 36
2
votes
1 answer

Does utf8json used in elastic v7.x support user defined custom formatters?

I've got an interesting situation whereby elastic v7 default utf8json has managed to serialize my object, but is unable to de-serialize it correctly. public class MyClass : FlagsSet { [JsonIgnore] public bool IsActive …
stoj
  • 1,116
  • 1
  • 14
  • 25
2
votes
1 answer

Direct json to StructureMap serialized byte[]

I have the following JSON (received as byte[] from a web socket): { "ev": "T", // Event Type "sym": "MSFT", // Symbol Ticker "x": 4, // Exchange ID "i": "12345", // Trade ID "z": 3,…
morleyc
  • 2,169
  • 10
  • 48
  • 108
2
votes
2 answers

Utf8Json deserialize to type based on marker field

With Json.NET - Newtonsoft I have successfully used custom contract deserializers and json converter to select the deserializer based on a tag (in the case below ev). In summary I am looking to achieve the same with Utf8Json, full details below: //…
morleyc
  • 2,169
  • 10
  • 48
  • 108
2
votes
0 answers

Custom JsonFormatter in Utf8Json is ignored

I have this simple JsonFormatter: public sealed class Int64StringConversionFormatter : IJsonFormatter { public void Serialize(ref JsonWriter writer, long value, IJsonFormatterResolver formatterResolver) { …
amiry jd
  • 27,021
  • 30
  • 116
  • 215
1
vote
1 answer

mongocxx mongosh db.currentOp BSONError: Invalid UTF-8 string in BSON document

I use debian9 and debian10 mongocxx driver to insert data in mongodb 6.0. Then I use mongosh 1.6 for monitoring ops with db.currentOp. And I get an error BSONError: Invalid UTF-8 string in BSON document. I can switch on profiling and look for ops…
1
vote
2 answers

JsonNode.Parse: error parsing text with accents

I am trying to parse a Latin text with the Parse method of JsonNode from System.Text.Json class. But when the text contains accents, the method returns escape characters. var jsonString = File.ReadAllText(path, Encoding.GetEncoding(1252)); …
1
vote
1 answer

Utf8Json: is not registered in this resolver(EnumUnderlyingValueResolver). An exception occurs while serializing an enum as number

I am trying to serialize a c# object with an enum property to JSON using utf8json and format its enum values as numbers using EnumResolver.UnderlyingValue, however when I do so an exception is thrown. How can I prevent this exception? I have these…
Arman
  • 33
  • 5
1
vote
1 answer

How to serialize json with fields name as datamember only?

I have a POCO like this: public class Process { public Process() { } [DataMember(Name = "lang_code")] public string LCode { get; set; } [DataMember(Name = "data_currency")] public string Currency { get; set; } …
AndyP
  • 527
  • 1
  • 14
  • 36
1
vote
1 answer

How to get JSON body from the stream in C# efficiently?

I am using Utf8 json library to deserialize my JSON using DeserializeAsync method of JsonSerializer class. And sometimes I am seeing it is throwing exception as - Arithmetic operation resulted in an overflow. So it looks like my JSON data has a…
AndyP
  • 527
  • 1
  • 14
  • 36
1
vote
1 answer

Check for exception type inside Exception catch block and log it

I am using Utf8 json library to deserialize my JSON using DeserializeAsync method of JsonSerializer class. And sometimes I am seeing it is throwing exception as - Arithmetic operation resulted in an overflow. So it looks like my JSON data has a…
AndyP
  • 527
  • 1
  • 14
  • 36
0
votes
1 answer

Force UTF8 for Hubspot > Zapier > Webhook > CRM

I have a problem with my automation via Zapier. In Hubspot I am creating deals and triggering those via Zapier. Once my Zap is triggered the Data goes to my Webhook in JSON format. The problem: The data is non UTF-8 For some reason the Zapier…
0
votes
2 answers

Netcore 3.1 UTF8JSON Serializer adding literal Key and Value to result

Netcore 3.1 UTF8JSON Serializer adding literal Key and Value to dapper query result. public async Task> JsonQs(string sql, object param = null, CommandType commandType = CommandType.StoredProcedure) { using SqlConnection conn = new…
froodo
  • 87
  • 2
  • 14
1
2