Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Trailing comma #43

Closed
jdevera opened this Issue Oct 17, 2012 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

jdevera commented Oct 17, 2012

I'm using a python script to parse the vimorgsources.json file and it's choking when trying to parse it doe to the trailing comma in the last entry, since there is nothing but a closing bracket after it. I think the json parser module should be OK with this but since it's not, could you please skip that comma if you have some spare time for this. I'd greatly appreciate it.

Collaborator

ZyX-I commented Oct 17, 2012

You can use YAML parser, less restrictive json decoder (like demjson) or just eval (see how this is implemented in VAM: two regexs and it is safe as far as I see, including being safe for python). Neither of this have any problems with trailing comma.

Contributor

jdevera commented Oct 17, 2012

Thanks for the alternatives!, The yaml parser swallows that trailing comma with no complaints, so this is not blocking me any more. However it means that the json file is not really valid json. If you are happy with this, so am I, please feel free to close the issue.

Owner

MarcWeber commented Nov 30, 2012

Tell us what you're doing. We want to learn from your ideas. You're welcome. Consider using the dump from www.vim.org/script-info.php which should be valid json. Why perl adds "," - no idea. IE does not like it, most other browsers accept it. If you want us to change it - make us understand why its worth spending our time on it.

Collaborator

ZyX-I commented Nov 30, 2012

Because there is no way I could configure perl to output in “one plugin by line” mode. Thus I dump the key, dump the value (in oneline mode) join them and print to the file, with preceding { and following }.

Contributor

jdevera commented Nov 30, 2012

I'm using the big json file as a convenient way to get a list of available colorschemes in vim.org. The final goal is to make something like the Vim Colorscheme Test but based only on colorschemes available in vim.org.

The perl script you use to generate the json file does not special-case the last script, so it still adds a trailing comma. So, in effect, the json file is not really valid json.

However, for my particular usage, I could simply switch to the yaml parser, which is happy enough with that comma. So as I already mentioned, it is just up to you to change that or not, depending on how important it is for you to make the json file with all the scripts be valid json.

Owner

MarcWeber commented Apr 4, 2013

Could be fixed, but nobody is interested in this issue anymore probably. Please note that filtering by type may make you miss some colorschemes which are provided by scmsources.vim only - but getting to know which of those sources provides colorschemes requires checking out sources.

@MarcWeber MarcWeber closed this Apr 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment