What is the most elegant way to return a simple value in json format?

I'm triying to expose some data with a webservice that returns different json text based on the requested URL.

For some requests, the output is clear for me, because I'm returning objects, arrays of data, or a mixture. But for simple values, I don't know what is the most elegant way of returning the value.

For example, let's say I'm requesting http://host.com/last-client-id

Should I return

  • ["1000"] - an array with one element?
  • {"id": "1000"} - an object with the name of the value?
  • "1000" - a simple string?
  • What do you think?

    链接地址: http://www.djcxy.com/p/48084.html

    上一篇: 如何使用memcache加快速度

    下一篇: 以json格式返回简单值的最优雅方式是什么?