Json serialize, deserialize (dont try to be smart) #99064
Replies: 2 comments 2 replies
-
I'm not sure I follow what the requirement is. You seem to suggest that the parser is automatically converting ints to strings or vice-versa, however that is not the case (the notable exception being It also isn't clear to me how the above relates to the extension methods that you listed. Because |
Beta Was this translation helpful? Give feedback.
-
Not sure where the ticket is maintained, i seam to loop in redirections. |
Beta Was this translation helpful? Give feedback.
-
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
Json can be serialized and deserialized with csharp.system.text.json.
However, the current parser imposes huge risks, as it tries to be smart and does do type conversions automatically.
What's needed, a way to enforce as string, or as number, or to disable the automatic conversions.
Cause when we deal with json we often deal with other code languages who are quite clear on the json standards.
We don't need the c# language to ignore those rules ea "123" is a string 123 is a number.
Whats needed an extension JsonDocument.ParseString($""selectedCar": "{selectedCar}""). RootElement;
Or have it a little bit smarter JsonDocument.ParseString(atributename,stringvalue);
This way existing code could still use the auto conversion, or write as string.
something alike below should be in the C# language
So one can do
And yes one can say but you have a written extension solution why post this ?... cause it's 2024 the world uses JSON standards !
And if it's as simple as this why not implement it in the language?
Original Comments
Feedback Bot on 2/19/2024, 10:55 PM:
(private comment, text removed)
Original Solutions
(no solutions)
Beta Was this translation helpful? Give feedback.
All reactions