Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How/when to use json?

So, I know the definition of json, I know its a lightweight data format.

As I am not an expert on this subject I would like to know, when can I use JSON, in which scenarios or applications? How to do it in c#?

I suppose I would Use Json only in applications where I intend to use ajax?

I use Json to call web service methods only so that I can use javascript to show the results without a postback?

Is JSON something to be used only in web forms applications? asp.net mvc applications? silverlight? winforms?

like image 549
Luis Valencia Avatar asked Feb 23 '23 18:02

Luis Valencia


2 Answers

Well, you ask too many questions. My personal view on JSON:

1) JSON is a good tool if you need to deal with AJAX (as Sietse pointed out it should be called AJAJ in this case) and webservices

2) JSON is a good tool if you generally need to communicate between different platforms. I used it for communication between PHP and C# program because JSON is implemented in so many languages it is natural to use it and avoid creating custom communication procotol.

like image 120
Martin Vseticka Avatar answered Mar 02 '23 18:03

Martin Vseticka


JSON can be useful whenever you want to pass data between programs written in two different languages. It's often used in AJAX scenarios, like in your example - a Javascript client receiving data from a server written in C#. But it can be useful in any other situation where your data has to cross a language barrier.

Other alternatives to JSON are XML, SOAP, CSV, YAML, etc...

JSON is popular because it can transfer data reliably in a well-defined format (unlike CSV) and is also easily human readable (unlike SOAP).

like image 28
Mark Byers Avatar answered Mar 02 '23 17:03

Mark Byers