How can I read JSON from a file stored locally?

前端 未结 2 1110
梦如初夏
梦如初夏 2021-02-08 05:38

I am attempting to use JSON.Net to load in a JSON file stored locally on an ASP.Net MVC 4 site, but am having trouble pointing to the file. Here is what I am trying to do:

2条回答
  •  被撕碎了的回忆
    2021-02-08 06:13

    You are passing in the path and filename as your JSON payload. You need to open the file (eg. FileStream) and read the contents into a variable (eg. StreamReader) and pass the file contents as the payload to the deserializer.

提交回复
热议问题