JSON Unmarshal struct case-sensitively

Is there a way to make json.Unmarshal not accept case insensitivity? I get JSON with tags such as "e" and "E", and would like to decouple the object with the tag "e", but ignore the one that has "E". Right now, the only solution I found was to define a structure containing both tags and then just ignore the β€œE” tag, but I'm looking for a cleaner solution.

From the official doc:

To decouple the JSON into the structure, Unmarshal matches the incoming keys of the objects with the keys used by the marshal (either the name of the structure field or its tag), preferring an exact match, but also accepting case insensitivity.

+4
source share
1
+3

Source: https://habr.com/ru/post/1694170/


All Articles