This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I'm hand-throwing a bunch of AJAX & JSON code (can't use open source without a hassle) and wondered about the line I found in several JSON examples. (Had to write "evil" for "e v a l" to get by the Ranch's h4x0r filters.)
Any reason not to say ...
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
One could argue that the first approach makes more sense because the variable is declared "for real" and assigned the results of the evaluation, whereas the second approach embeds the variable declaration within the string which ends up with the same results but is more implicit.
Any other good approaches?
The header approach is liked because it doesn't pollute the data the way adding a property to the returned object (in JSON notation, of course) would.