On Aug 20, 7:30 pm, Andy Chu <[email protected]> wrote:
> Yeah good question. There are a few inherent limitation in the JSON keys:
>
> 1. Dots are interpreted as operators
> 2. {} can't appear because those are delimiters
> 3. @ can't because that's the cursor
> 4. I believe | can't occur either (should specify this better)
>
> Writing a custom formatter wouldn't work because the key lookup
> happens independent of formatting.
I did actually get this working using a custom formatter that does a
lookup on the cursor (or it can do a lookup on a particular JSON dict
of course). For example: {@|rawlookup foo/bar/baz.txt}. This
actually works quite nicely as I need to do some additional processing
on "foo/bar/baz.txt" anyway so I can extend this to fit my needs. The
Python implementation was:
def more_formatters(formatter_name):
if formatter_name.startswith('rawlookup '):
def rawlookup(a):
return a[formatter_name[len('rawlookup '):]]
return rawlookup
Thanks,
Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JSON
Template" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/json-template?hl=en
-~----------~----~----~----~------~----~------~--~---