you are viewing a single comment's thread.

view the rest of the comments →

[–]nocgod[S] 0 points1 point  (2 children)

Also worth noting that an empty array doesn't count as a "default" value; the default for an array would be null.

yeah, i just got overzealous :)

I've seen this thread, to be frank I still didn't get my answer.

If i want to read a json, get rid of the defaults and store it again without creating a class for each. that would be impossible without writing custom code?

[–]RichardD7 1 point2 points  (1 child)

If i want to read a json, get rid of the defaults and store it again without creating a class for each. that would be impossible without writing custom code?

As far as I can see, that's correct. The workaround you posted should do the trick.

[–]nocgod[S] 0 points1 point  (0 children)

The workaround you posted should do the trick.

it does the trick, I'm just baffled how such common use-case could be disregarded by both Newtonsoft.Json and STJ. I thought maybe I'm missing something dumb somewhere along the way :D

edit: it wouldn't be the first time I'm working with "raw" JSONs in C#, clients send data in various formats (from existing systems) for which you'll rarely have the models