All-uppercase strings and `camelCase` JSON serialization (in .NET)

I was recently debugging an issue where two systems expected the contract to be using the camelCase style, but miscommunicated because they assumed a different transformation result for an all-uppercase string like URL:

  • System 1 serialized it as url
  • System 2 serialized it as uRL

Which of them was right, and which was buggy?

The short answer is that there’s no single industry standard defining what is right here. Libraries might handle edge cases differently. If you need compatibility, it’s helpful to examine the libraries you need to ensure they are doing what you expect.

Experiment: .NET serializers vs all-uppercase strings

Acronyms and abbreviations are common in property names. Objects might contain properties containing strings like URL, API, HTTP etc. Such property names are transformed differently depending on the serializer and settings you use.

This experiment examines how popular .NET JSON serializers handle acronym casing when converting strings to camelCase during serialization.

Serializer Style URL URLPath MyURL IOStream M4AFileName
Newtonsoft.Json CamelCase url urlPath myURL ioStream m4AFileName
System.Text.Json CamelCase url urlPath myURL ioStream m4AFileName
Newtonsoft.Json Default URL URLPath MyURL IOStream M4AFileName
System.Text.Json Default URL URLPath MyURL IOStream M4AFileName
Newtonsoft.Json SnakeCase url url_path my_url io_stream m4_a_file_name
System.Text.Json SnakeCaseLower url url_path my_url io_stream m4_a_file_name
Newtonsoft.Json KebabCase url url-path my-url io-stream m4-a-file-name
System.Text.Json KebabCaseLower url url-path my-url io-stream m4-a-file-name

Conclusions

The key learnings for me are:

  1. In camelCase style, acronyms at the beginning of property names are handled differently from the ones in the middle/end of the string.
  2. System.Text.Json and Newtonsoft.Json transform acronyms to lowercase in the same way in all cases I tested, suggesting high compatibility of those style transformations.
  3. Many state-of-the-art LLM models are confused about this in 2025 and suggest the output would lowercase only the first letter (e.g., URL → uRL), which is not true for the popular .NET serializers.
  4. If you want to convert a string to camelCase style, don’t let LLMs trick you into oversimplified implementations that only replace the first character of the string. Instead, use a mature library like System.Text.Json to do it for you!

Good luck 🙂

No comments yet, you can leave the first one!

Leave a Comment