-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashes in json identifiers #34
Comments
I reproduced this. Also, another observation.
|
This is the intended behavior. Moreover it has always worked this way and it is also mentioned in the doc:
That said, I've been thinking to allow arbitrary characters in JSON field names, but only when they are explicitly specified via the |
I admit that I have not seen that piece of documentation. |
I agree with Dennis, the main issue here is consistency. Why I carefully read the docs on encodings, and this dash-underscore translation in JSON looks arbitrary. I assume there were non-obvious technical reasons to do that. Could you highlight them? |
Two points. First, unlike XML, JSON maps nicely to programming languages (e.g. JavaScript). However, most languages don't allow dashes in identifiers. For this reason, it makes a lot of sense to follow a conventional style for naming field identifiers in JSON which assumes using underscores. Second, XML does't map to programming languages as seamlessly as JSON. Usually, some level of transformation is required anyway. Because of that, I decided to go with dashes in XML identifiers -- they just look nicer. Haven't really heard any complaints from Piqi/XML users so far. |
JSON maps only nicely to javascript, for all others it needs to go to a similar parsing and transformation process as XML, so there is no difference there. |
@spil-dennis suppose you are right and I understand that you like dashes in identifiers even more than I do. How would you convince existing Piqi users that it is worth breaking backward compatibility of existing protocols and existing distributed applications that rely on identifiers with underscores? If you really like dashes in JSON field names you can contribute optional support for it. I'll be happy to merge it. |
I don't care for dashes or underscores either way, just that there should not be arbitrary diverging from the specification. Piqi uses dashes, so it's a bit strange to use that everywhere, but in one thing? So can I conclude from this discussion:
I will make an updated patch allowing to switch this behaviour. |
Great! Thanks. |
The json parser in 0.6.4 does not allow for dashes in json identifiers.
Given the following piqi definition (in dash.piqi):
I would expect the following:
What actually happens is:
And the following should fail, but interestingly succeeds in parsing AND converting:
But the output DOES conform to the piqi definition..
The text was updated successfully, but these errors were encountered: