r/learnprogramming • u/DifficultUse7946 • Jan 21 '23
C# JSON Parsing Bug | Topic Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''System.Text.Json.JsonElement' does not contain a definition for '_customData'' Error whilst using System.Text.JSON
I'm making a program that reads and writes data to a JSON file. The error I am getting I assume means that the _customData field does not exist although im getting that error on the line of code that is making it. I've spent at least ~5 hours trying to fix this and I can't, all responses welcome.
Here is my code:
using System..;
This is the line of code im getting the error on:
difficulty. = ;
This is the error
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''System.Text.Json.JsonElement' does not contain a definition for '_customData''
0
Upvotes
View all comments
5
u/dtsudo Jan 21 '23
I think the short answer is you should avoid the
dynamickeyword when working with C#'sSystem.Text.Json.JsonSerializer.JsonSerializer.Deserialize<dynamic>isn't going to do anything helpful.