最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Namespaces in JSON - Stack Overflow

programmeradmin1浏览0评论

Is there such a thing as JSON namespaces, just like XML namespaces? Has anyone created a spec or libraries for this? Is this a good or a terrible idea?

I want to make a data spec that can be represented in XML as well as JSON. However I also need the namespace concept, that the data can be extended by annotations in different vocabularies.

To be more specific, this is about representing events. My schema will describe the event in basic terms (time and location), though if you think about it, events can be annotated with different information e.g. attendees or image URLs which I don't want to specify in my schema.

Is there such a thing as JSON namespaces, just like XML namespaces? Has anyone created a spec or libraries for this? Is this a good or a terrible idea?

I want to make a data spec that can be represented in XML as well as JSON. However I also need the namespace concept, that the data can be extended by annotations in different vocabularies.

To be more specific, this is about representing events. My schema will describe the event in basic terms (time and location), though if you think about it, events can be annotated with different information e.g. attendees or image URLs which I don't want to specify in my schema.

Share Improve this question edited Sep 23, 2010 at 11:06 Jerome asked Sep 23, 2010 at 10:41 JeromeJerome 1,1921 gold badge7 silver badges12 bronze badges 6
  • You probably mean JavaScript namespaces; JSON is just a notation (JavaScript Object Notation). – Marcel Korpel Commented Sep 23, 2010 at 10:42
  • 2 Namespaces do not exist in JSON in it's current specification – BeRecursive Commented Sep 23, 2010 at 10:49
  • 6 @Marcel no I do mean JSON, since it's a data format similar to XML. – Jerome Commented Sep 23, 2010 at 10:58
  • 1 See also Mark Nottingham's Thinking about Namespaces in JSON for added perspective and suggestions. – John McCarthy Commented Jan 27, 2014 at 19:35
  • 1 See also: lists.xml.org/archives/xml-dev/201506/msg00024.html – dreftymac Commented Oct 17, 2019 at 2:14
 |  Show 1 more comment

3 Answers 3

Reset to default 6

JSON-LD might help :

"JSON-LD (JavaScript Object Notation for Linking Data) is a lightweight Linked Data format that gives your data context."

JSON Schema might be the right thing for this:

http://json-schema.org/

Althought I don't know how well it's implemented.

This is quite an old thread, but there are JSON prefixes, which are almost like namespaces. If you are using Java server-side with Jettison, you can easily meet them.

发布评论

评论列表(0)

  1. 暂无评论