-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Using Ruby's irb:
% irb
Require the gem:
3.0.0 :004"> require "compactdata"
=> true Tests 1-3:
3.0.0 :009"> CompactData.generate({"a\\t":1})
=> "a\\t=1"
3.0.0 :010 > CompactData.generate({"a\t":1})
=> "a\t=1"
3.0.0 :011"> CompactData.generate({"a\d":1})
=> "ad=1" 1.\t is a control character (tab) so the double backslash is retained, this would seem correct behaviour.
2.\t (tab) would be retained in the key, which would seem correct behaviour.
3. \d does not represent a control character so Ruby strips out the backslash when it creates the hash and before it gets passed to CompactData.generate, this is demonstrated here:
3.0.0 :012 > {"a\d":1}
=> {:ad=>1}
In the following example, we create a hash with one pair; the key is key\\key and value is value\\value
This is the output from JSON.generate
{"key\\key":"value\\value"}
This is the output from CompactData.generate:
key\key=value\value
Here are some questions for consideration:
- Should the backslash in the CompactData string be escaped too?
- Should we ban control characters in keys?
- Should we consider every key a quoted string?
Metadata
Metadata
Assignees
Labels
No labels