Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Valid JSON (jsonlint) couldn't be Deserialize

So im trying to Deserialize json string which is valid (checked by jsonlint) but somehow this code:
Code
dynamic data = JsonConvert.DeserializeObject<dynamic>(txtRes.Text);
works but when i try to get and element like
Code
data.skuModule
i get an error
Quote:Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''string' does not contain a definition for 'skuModule''


plus i used
Code
JsonConvert.ToString(txtRes.Text);
function to escape all the needed chars

the json string is shown by a rich text box and it is:
https://pastebin.com/VzM01szD
which library you using
try data["skuModule"]
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
this is what im getting
Code
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'The best overloaded method match for 'string.this[int]' has some invalid arguments'

and im using using Newtonsoft.Json;


(Aug 12, 2020 10:32 AM)HFDone Wrote:  which library you using
try data["skuModule"]

Answer to you
try this data[0].skuModule
0 is the json array you want
check doc https://www.newtonsoft.com/json
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Aug 12, 2020 11:28 AM)HFDone Wrote:  try this data[0].skuModule
0 is the json array you want
check doc https://www.newtonsoft.com/json

Getting this error
Code
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ''char' does not contain a definition for 'skuModule''

god dammit maybe there is something wrong with my json string although the JSONLint says its ok


Quick update guys apparently my json was fucked.... it had , at the end and a missing { at the start
but never mind boys thanks for the help
So, has this been resolved?
[Image: 4wssj.gif]


If you're looking to hire a Python/Java/Scheme/SQL/PHP programmer, contact me.

xerotic Wrote:Ask Majin Goten if you need help, he is sexy with Python
StaTiX Wrote:You're the king of the python section
(Aug 15, 2020 02:25 AM)Majin Goten Wrote:  So, has this been resolved?

It is :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by roosiinfidel09May 26, 2021 06:32 AM 1 274 May 26, 2021 06:32 AM
Last Post: h0lyl337
[.NET] by outlawNov 28, 2020 04:25 AM 12 367 Nov 28, 2020 04:25 AM
Last Post: Rmdy
[Python] by XoggApr 24, 2020 01:14 AM 2 138 Apr 24, 2020 01:14 AM
Last Post: Lindros