简体   繁体   中英

Commenting conventions in Java

All Java developers do know the conventions for commenting using slashslash ( // Comment ) and slashstar ( /* Comment */ ). But I came across a documentation of JSONArray of codehaus , starting from line 69:

Comments written in the slashshlash, slashstar, and hash conventions will be ignored.

What is hash conventions? How is it used? Couldn't get the relevant good result googling it.

You are linking to the documentation of a JSON parser, so this is not about comments in Java, but comments in JSON.

In standard JSON, there is no syntax for comments at all .

This parser is more flexible and allows comments in three popular varieties:

{  "x":  1,      // slash-slash
   "y":  2,       /*  slash-star 
                 */
   "z":  3       # hash
}    

You cannot use these comments in portable JSON, but if those are files that stay inside of your system and will be run through that particular parser, this is quite convenient (and you cannot use "hash" comments in Java).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM