json2xls
json2xls copied to clipboard
Doesn't work with '.' in keys
When the key name has a '.' this seems to fool json2xls, e.g.
{"lang.contextButtonTitle":"nice", "lang.decimalPoint":"true"}
I wouldn't normally use '.' in a key, but these were added automatically by a json flattener (https://www.npmjs.com/package/flat)
Thanks for the report. I'm not sure what to do with this. There seem to be two options:
- allow dots in keys as you describe
- when resolving fields from the json, treat fields with dots as json paths and descend into the structure.
What I may end up doing is checking whether the key exists and if not, try to descend into the structure.
In any case, the current behaviour seems flawed
Seems sensible, thanks. Incidentally the 'flat' module that caused this in the first place (by using '.' in the key names) has a 'delimiter' option anyway, so in my case it's easy to avoid the problem by using a delimiter like '_' instead of '.' (and your module then works just fine). But I thought I'd mention it anyway.
have the same problem here. Column name has a '.' In my case I cannot switch do another delimiter as the export format is a given could you please fix it? many thanks
I would also suggest to allow dots in column names, it's used quite regularly (for instance a column "Invoice Nr.")
I would advise using object-path to retrieve the value (it allows default values if path is not found) https://github.com/mariocasciaro/object-path
Got the same problem. There is a pull request too on this. Waiting for the fix. :)