Skip to content

Conversation

benjamn
Copy link
Owner

@benjamn benjamn commented Mar 18, 2017

Instead of encoding objects as object literals with (possibly repeated) string keys, this commit encodes them as an array of (interned) keys and values:

> ARSON.encode([{lonnngKeyName:"a",a:true},{b:false,lonnngKeyName:"b"}])
'[[1,2],["o",3,4,4,5],["o",6,7,3,6],"lonnngKeyName","a",true,"b",false]'
> ARSON.decode(_)
[ { lonnngKeyName: 'a', a: true },
  { b: false, lonnngKeyName: 'b' } ]

Notice that the key string "lonnngKeyName" appears only once in the encoding.

Here's the output without this change applied:

> ARSON.encode([{lonnngKeyName:"a",a:true},{b:false,lonnngKeyName:"b"}])
'[[1,2],{"lonnngKeyName":3,"a":4},{"b":5,"lonnngKeyName":6},"a",true,false,"b"]'
> ARSON.decode(_)
[ { lonnngKeyName: 'a', a: true },
  { b: false, lonnngKeyName: 'b' } ]

@KnorpelSenf
Copy link

See #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants