substringing and slicing not working..
i've tried everything on planet earth it feels like
etc...
i'm converting a
NewtonSoft.JValue
to a string and none of these have worked, and the .Substring
method exists on some of the description strings but not all of them??19 Replies
Any reason you're using
JValue
(and Newtonsoft) instead of just deserializing to a proper class?
Also, don't do this
it's just
im writing multiple commands, and it seems unnecessary to write classes for every result
Ah, so you're willingly getting rid of type safety and making your life harder for no reason
Understandable
okay but
If writing those classes manually is such a bother, just generate them from JSON
how would i make a class for a returned http result
thats an array?
Uh, deserialize to a list...?
Or an array?
what json toolset do you recommend?
System.Text.Json
There's no need for any 3rd party libraries
Far as generating classes from JSON goes, both Rider and VS have it built-in
If not, $jsongenInstantly parse JSON in any language | quicktype
Whether you're using C#, Swift, TypeScript, Go, C++ or other languages, quicktype generates models and helper code for quickly and safely reading JSON in your apps. Customize online with advanced options, or download a command-line tool.
Convert JSON to C# Classes Online - Json2CSharp Toolkit
Convert any JSON object to C# classes online. Json2CSharp is a free toolkit that will help you generate C# classes on the fly.
There are online converters
hmm
let me try hold on
Angius#1586
REPL Result: Success
Console Output
Compile: 849.384ms | Execution: 159.421ms | React with ❌ to remove this embed.
is the deserializer able to
convert lowercased values to uppercased
id
-> Id
Values or property names?
Angius#1586
REPL Result: Success
Console Output
Compile: 786.807ms | Execution: 122.463ms | React with ❌ to remove this embed.
names
oh
it works
let me try now
looking good so far i think
I still see one lowercase property name there, but yeah, LGTM
oh yea
id
tried it with this
the returned value is
{"data": {"url: "link here"}}
oh i think i forgot to change the type hold on