开发者

Basic JSON question

开发者 https://www.devze.com 2023-03-25 03:48 出处:网络
I kn开发者_开发百科ow it might sound silly but how do I determine a website supports JSON? I know what/how JSON use for a long time, but I do not know how could I technically know whether a

I kn开发者_开发百科ow it might sound silly but how do I determine a website supports JSON? I know what/how JSON use for a long time, but I do not know how could I technically know whether a server has json support. Do I need to manually request json file to check whether it suppports or not? Any comment would be appreciated !


You can check what is the content type of server response, usually this is

application/json


(1) "Websites" don't really serve up JSON; the notation syntax isn't really meant for page rendering, it's made for data transmission.

(2) What oftentimes serves up JSON are APIs (like those of Facebook and StackExchange). These APIs usually use HTTP GET, POST, PUT, and DELETE methods to interact with services they provide, and (sometimes optionally) transmit the bulk of the payload data in JSON format.

(3) It doesn't really make sense to ask where to get JSON. If you'd simply like to play with some JSON for educational purposes, Python, PHP, Javascript, etc. all have great built-in support. What you ought to be looking for are the services that you'd like to utilize, and whether or not they support JSON. If the service is new, or popular, and has relatively good API support, odds are it will work with JSON.


As far as I know, JOSN is just a format, like XML. You can create JSON page by hand, or use easy functions in a lot of the major coding languages.

Example: PHP does this easily with json_encode(String) json_decode(String). So, as far as my knowledge goes, every server / website can support JSON, though some might not have the updated PHP or whatever coding language you may be doing, to support easy implementation of JSON.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号