✅ problem
I call a function that returns something like this
How can I turn this into a Array ?
18 Replies
so how do u print this string?
so give us some basic information (the code u showed earlier as well)
this is a http request to lua function
C#
Lua
I would start by questioning why a method returns this string in the first place and not an array
because, i might not be able to help ya, so if anyone else sees this thread they might be able to help if they see the whole thing
What do you mean "http request to a LUA function"?
I see no HTTP requests here
we were in #chat first
Ah, I lack context then, carry on
now all context is given
this string, how u do u print it? thats not given from the shown code
or do u see it via debugger?
I actually see ["Value 1","Value 2"] I just wanted to say that this is the type of string
if its
["Value 1","Value 2"]
(which is valid json, a list with 2 string elements), instead of "["Value 1","Value 2"]"
which is invalid json, it makes quite a difference
u r using Newtonsoft.Json
, right?yes
and u want to deserialize it to a string array?
as in
string[]
?
because that would be a simple string[] arr = JsonConvert.DeserializeObject<string[]>(content);
what type is item
btw?ow it worked, thank you very much
if it worked, then this ⤴️ with the extra
"
at the start and the end was just about how u displayed the content
and if u r on .NEt 7 or later u should really look into using System.Text.Json
instead, its since .net 7 the defacto standard unless u have some niche cases regarding invalid json
@- SinAw if ur question is answered, please mark this thread as that by $close -ing itUse the /close command to mark a forum thread as answered
ok i use it , thank you very much
$close -ing
Use the /close command to mark a forum thread as answered