jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
Jettison
  • Jettison
  • JETTISON-42

Writing keys

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.0
  • Fix Version/s: 1.4
  • Labels:
    None
  • Number of attachments :
    2

Description

It will be better to write keys without commas if there is no space in the key name. It's less verbose.
Also it will be great to have support for layout. A simple callback interface could be provided to allow insertion of white spaces before and after writing keys, values, etc. Right now everything is dumped in a single line.

Thanks

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    JETTISON-42-Quotes.patch
    06/Jun/08 12:24 PM
    2 kB
    Adrian Tarau
  2. Text File
    JETTISON-42-Quotes.patch
    07/Jun/08 10:25 PM
    45 kB
    Adrian Tarau

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Adrian Tarau added a comment - 06/Jun/08 12:24 PM

Patch , key quotes.

If you think a JSONLayout makes sense, I can send you a patch with it.

Thanks.

Show
Adrian Tarau added a comment - 06/Jun/08 12:24 PM Patch , key quotes. If you think a JSONLayout makes sense, I can send you a patch with it. Thanks.
Hide
Permalink
Adrian Tarau added a comment - 07/Jun/08 10:25 PM

'-' must be escaped also. I added

public static boolean isWhitespace(char c)

{ return c == ' ' || c == '-' || Character.isWhitespace(c); }

additional characters can be added.

Show
Adrian Tarau added a comment - 07/Jun/08 10:25 PM '-' must be escaped also. I added public static boolean isWhitespace(char c) { return c == ' ' || c == '-' || Character.isWhitespace(c); } additional characters can be added.
Hide
Permalink
Tatu Saloranta added a comment - 09/Jun/08 12:46 AM

I think it would be wrong to add such checks to "isWhitespace" method. Hyphen is not a white space.
I assume hyphen would be added to indicate that quoting is mandatory for a key (presumably because of some external constraints – it doesn't have any special significance for json itself); if so, I think a new method should be created (containsQuotableChar() or whatever) to give better explanation of what it is to do.

Beyond this, is the suggestion that String values without spaces should not be surrounded by quotes?
It seems bit odd, given that such output is not legal JSON content. But if such an option is added, default should definitely be to fully enclose all String values (including) keys within double quotes, as mandated by json specification.

Show
Tatu Saloranta added a comment - 09/Jun/08 12:46 AM I think it would be wrong to add such checks to "isWhitespace" method. Hyphen is not a white space. I assume hyphen would be added to indicate that quoting is mandatory for a key (presumably because of some external constraints – it doesn't have any special significance for json itself); if so, I think a new method should be created (containsQuotableChar() or whatever) to give better explanation of what it is to do. Beyond this, is the suggestion that String values without spaces should not be surrounded by quotes? It seems bit odd, given that such output is not legal JSON content. But if such an option is added, default should definitely be to fully enclose all String values (including) keys within double quotes, as mandated by json specification.
Hide
Permalink
Adrian Tarau added a comment - 09/Jun/08 8:26 AM

Tatu,

You are right, isWhitespace is not an appropriate method name anymore, containsQuotableChar is a better name.

I was looking for a library which will allow my to serialize server side response as JSON but also to generate JavaScript code(using ExtJS library for front end) - since the format to create objects are the same.

Writing an object like this :

new Ext.Window({
el:'hello-win',
layout:'fit',
width:500,
height:300,
closeAction:'hide',
plain: true,

items: new Ext.TabPanel(

{ el: 'hello-tabs', autoTabs:true, activeTab:0, deferredRender:false, border:false }

),

buttons: [

{ text:'Submit', disabled:true }

,{
text: 'Close',
handler: function()

{ win.hide(); }

}]
})

looks better that :

new Ext.Window({
"el":'hello-win',
"layout":'fit',
"width":500,
.....
})

and not only ExtJS skips quoting keys, jQuery and other JS libraries.

This library could use by default quotes, but it should have an option to turn on an automatic quotes. Hypen seems to be a special character, if is present quotes must be present.

Thanks.

Show
Adrian Tarau added a comment - 09/Jun/08 8:26 AM Tatu, You are right, isWhitespace is not an appropriate method name anymore, containsQuotableChar is a better name. I was looking for a library which will allow my to serialize server side response as JSON but also to generate JavaScript code(using ExtJS library for front end) - since the format to create objects are the same. Writing an object like this : new Ext.Window({ el:'hello-win', layout:'fit', width:500, height:300, closeAction:'hide', plain: true, items: new Ext.TabPanel( { el: 'hello-tabs', autoTabs:true, activeTab:0, deferredRender:false, border:false } ), buttons: [ { text:'Submit', disabled:true } ,{ text: 'Close', handler: function() { win.hide(); } }] }) looks better that : new Ext.Window({ "el":'hello-win', "layout":'fit', "width":500, ..... }) and not only ExtJS skips quoting keys, jQuery and other JS libraries. This library could use by default quotes, but it should have an option to turn on an automatic quotes. Hypen seems to be a special character, if is present quotes must be present. Thanks.

People

  • Assignee:
    Dan Diephouse
    Reporter:
    Adrian Tarau
Vote (0)
Watch (0)

Dates

  • Created:
    06/Jun/08 11:38 AM
    Updated:
    04/May/11 10:25 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.