I have an array of string
var ids = new string[] { "1408576188", "1750854738", "100001058197465" };
I want to pass this array of string as a json array into an API. For now, the API cannot accept the string returned from :
JsonConvert.SerializeObject(ids);
So I am figuring out that I am able to use the API by turning my ids
array into a JArray
object.
JArray.Parse(JsonConvert.SerializeObject(ids));
As you can see, I am doing a two operation in here, first I serialize the ids
array, then I parse the result into JArray
. Is there any way to convert my ids
array directly into JArray
object?
Did you try the FromObject
method:
var array = JArray.FromObject(ids);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With