-2

I've a problem with the serialization of JSON.

I need to pass a JSON file from a directory, without generating a JSON string, because the file automatically updates every 5 minutes. All the solutions that I've seen ask me to pass the JSON file as a string, like this:

string json="{ \"test\":\"some data\" }";

The language that I'm using is C#. I've already installed the class: "Newtonsoft.json.dll". My project is a Web-Services in VisualStudio 2012. Can anyone tell me how to do this without saving the JSON file as a string?

If you want more information, please tell me!

4

1 回答 1

2

我不确定我是否完全理解您的问题,但是也许您可以执行以下操作:

using (var streamReader = new StreamReader("fileName.json"))
{
    string json = streamReader.ReadToEnd();
    var deserializedObject = JsonConvert.DeserializeObject<SomeClass>(json);
}
于 2013-05-27T08:02:13.673 回答