2

I have an exe file I wrote in .NET which I want to read a .json file from a URI, and return a value in string format. I am pretty new to .NET and c# but can easily do this in PowerShell (using Invoke-RestMethod). I don't want to use an external library such as json.net (would like to distribute this as a single .exe). The only thing I found so far was System.Runtime.Serialization.Json - which looks like it will work but also seems extremely complex and difficult to use. Is this the library I should be using to perform this simple task? Is there an easier way to do this?

1

3 Answers 3

3

import System.Web.Script.Serialization, then use JavaScriptSerializer object.

Sign up to request clarification or add additional context in comments.

Comments

1

System.Runtime.Serialization.Json really isn't all that bad. Yes, it is the library you should use if you don't want to go third-party.

The exception to this is if your JSON is trivial. If it's trivial, just do the string parsing yourself.

1 Comment

The JSON has just a few objects. I can definitely parse it myself with much less code. I will do that.
1

If you don't want to parse your own JSON I think the System.Runtime.Serialization.Json namespace is your best bet without using an external library..

JSON.NET is the best if you can use an external library though

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.