I've been searching for this one for quite a while but can't find anything. Appologies then for the title, as there is a lot on converting content to String Arrays, which is not what I need.
I need a way to convert the contents of a JsonArray to string just as is. (Similar to JToken's .ToString()). My scenario is of such a nature that I need the string of an array just as is, irrigardless of the type/s contained within. There are ways of handling weakly typed json with ValueConverters, but I spesifically do not want to use them, as I need to pass the content of a field as a string to a Javascript Function in a WebView.
I have the following json (note markers indicating where string is desired) :
"highlights2":[
{
"_id":"highlight2-2850cb68121f9d4093e67950665c45fab02cec81",
"_rev":"9-c4345794001495104f8cbf5dd6999f3a",
"content":{ <---- Need this as string
"#roepman.17.0":[
[
233,
249,
"itsi-hl-gr"
],
[
298,
317,
"itsi-hl-bl"
]
],
"#roepman.19.0":[
[
5,
7,
"itsi-hl-gr"
]
]
}, <----- Up to here
"created":1434552587
}, //...more like this
],
"book":"book-930d62a2-9b7c-46a9-b092-f90469206900",
"serverTime":1435151280
Ideally I want to parse it into a list of the following type:
public class HighlightInfo2
{
public string _id { get; set; }
public string _rev { get; set; }}
public string content { get; set; }
public long created { get; set; }
}
However this is not possible, as the content of "content" is of type JsonArray. So to get past not having to specify a type for "content", I use this:
public class HighlightInfo2
{
public string _id { get; set; }
public string _rev { get; set; }}
public Dictionary<string, List<JsonArray>> content { get; set; }
public long created { get; set; }
}
But this means I still have to at some point convert the List< JsonArray > inside the dictionary to a string as I pass the content of "content" to a Javascript function in a webview later on.
Any way of converting the JsonArray to a string?