0
jsonResult["filePath"]
{[
  "D\\test.pdf"
]}

How to get this filepath? Cant able to convert this object into array.

Any other way to achieve this filePath?

Gokul Kumar
  • 389
  • 6
  • 16
  • Try a search for "how to parse Json in c#" - for example https://stackoverflow.com/questions/6620165/how-can-i-parse-json-with-c - if you ind the advice there useful, consider deleting this question. If you find it not useful, edit your question to say what you tried and why it didn't work. you can also paste your Json into http://QuickType.io to generate c# from it. Note that your Json should either have a name for the array or no curly brackets. Correct the device that creates this Json or trim/adjust before you parse – Caius Jard May 04 '20 at 07:35
  • 1
    JSON is wrong format – logeshpalani31 May 04 '20 at 07:39

1 Answers1

1

If you're talking about parsing the JSON looks like

{
    "filepath":[
        "D://test.pdf",
        "D://test2.pdf"
    ]
}

and get value from it via Json.net, you can just

JObject obj = JObject.Parse(jsonString);
MessageBox.Show(obj["filepath"][0].ToString()); // Showing "D://test.pdf"
Ryu
  • 271
  • 1
  • 12
  • Or use [`System.Text.Json`](https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to) in case of .NET Core 3.1 – aepot May 04 '20 at 07:49