Skip to content
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

Adding "true" and "false" strings to Bottle produces unwanted quotation marks #431

Closed
gsaponaro opened this issue Mar 5, 2015 · 3 comments

Comments

@gsaponaro
Copy link
Contributor

I have a module that needs to add the words true/false (actual strings, not boolean values) to a Bottle. However I observed that adding the strings true and false to a Bottle then printing it on screen shows quotation marks around these words, while other strings show no quotes. I guess it has to do with true and false being reserved keywords in C++.

Example:

Bottle bottle;
bottle.addString("word1"); 
bottle.addString("true");
bottle.addString("any_other_word");
cout << bottle.toString().c_str() << endl;

prints word1 "true" any_other_word <-- notice quotation marks around true. Is it possible to obtain word1 true any_other_word instead?

gsaponaro pushed a commit to robotology/poeticon that referenced this issue Mar 5, 2015
More precisely, they are written as "true"/"false" with quotation marks. See also robotology/yarp#431.
@gsaponaro
Copy link
Contributor Author

In the end, this is not really a problem for our project: the client that reads the Values from my Bottle works whether those quotation marks are present or not.

However, I am still curious about this behaviour, if it is expected of yarp to put those quotes around true/false, do you know @paulfitz @drdanz?

Please feel free to close this issue when you want.

@paulfitz
Copy link
Member

I think this behavior is to keep unquoted true/false free for eventual json compatibility. When converting the entire bottle, each element is serialized in a way that lets it be read again as the original type. You could ask bot.get(1).asString() if you expect a string, and there will be no quoting. Sorry for the confusion and delay responding.

@gsaponaro
Copy link
Contributor Author

Thank you, no problem.

/cc #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants