Share This

Search Robogenus @ Blogger.Com

Friday, September 13, 2019

How do I write comments inside a JSON document?

https://www.quora.com/How-do-I-write-comments-inside-a-JSON-document

Comments are not supported with JSON for reasons I consider stupid.  BUT, that doesn't mean you can't use them.  If you own the recieving application, you might get away with it.  I'm using JSON as a configuration file format in the application I'm building at the moment.  I have a lot of values I need to let the user set and I don't want to build a custom parser ... so ... I'm using JSON so I can serialize into my object in 1 line of code. Works great for that purpose.  Sometimes they want to add comments as to why they are setting value the way they are.  In this use case, the reasons for not allowing comments are completely invalid (I think they are always invalid but who cares what I think) ... anyway.  I've found that the library I'm using allows /* ... */ comments but doesn't allow // comments.


{

  "myObject": { /* this is my first comment that works just fine for me*/
      "foo":"bar", /* this is a comment that also works... after comma important */
      "foo2":"bar2" // this comment will throw an exception
  }
}

Textpattern CMS ­ A flexible, elegant and easy-to-use content management system

Textpattern CMS ­ A flexible, elegant and easy-to-use content management system

About Textpattern
Textpattern CMS is an elegant content management system that is free, open source software. Web designers, developers, publishers and bloggers love its flexibility and extensibility. It has a powerful, sophisticated engine that can be infinitely tuned to suit whatever type of website you can imagine.

Who is it for?
With its built-in simplicity, a blogger can start publishing in minutes. Designers and developers appreciate the ability to control all aspects of HTML and CSS from the administration interface, and with hundreds of plugins available, the power of Textpattern CMS is easily extended.

How does it work?
Textpattern uses built-in tags to determine how dynamic content should be retrieved and displayed. You have complete control over the content and presentation, making the CMS both simple and elegant to use.

The administration interface is minimalist, efficient and clearly labelled. Designers can quickly produce well-structured, standards-compliant websites while authors can get on with publishing and editing content. Textile, which uses just a few markers to nudge plain text into fully-formatted web content, is built-in.

Is it extensible?
The core features are greatly extended through the use of plugins. Need a special function? Find the plugin, copy and paste it into the plugin field and activate. Simple as that!

There’s no need to know any PHP or JavaScript coding to use Textpattern, though many web developers create plugins for all kinds of purposes. The friendly community forum will most likely make you a plugin if it hasn’t already been made. Unlike some other forums, the Textpattern developers themselves answer questions, listen to suggestions and write plugins too.

So it’s stable and secure, then?
Absolutely! The development team and community thoroughly test each release before it is made public. Be assured the software is robust, reliable, and mature.

Follow Me On