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

Usage of both parser and generator #8

Closed
leventesen opened this issue Jul 20, 2014 · 2 comments
Closed

Usage of both parser and generator #8

leventesen opened this issue Jul 20, 2014 · 2 comments
Labels
Milestone

Comments

@leventesen
Copy link

How can we use both generator and parser in the same Arduino sketch without getting namespace conflict errors?

@bblanchon
Copy link
Owner

My personal advice is to put the using statement in the function scope.
But this will only work if you use the parser and the generator in different functions.

Otherwise, you can simply use the namespace ArduinoJson and then prefix the names with Parser:: or Generator::.

Please also look at this blog post.

@bblanchon bblanchon added this to the 3.0 milestone Jul 24, 2014
@bblanchon
Copy link
Owner

I added an explanation in JsonGenerator/README.md and JsonParser/README.md:

Having a namespace conflict?

To be able to use both ArduinoJson::Generator and ArduinoJson::Parser in the same file, you need to do one of the followings:

  • Put the using statements into different functions
  • using namespace ArduinoJson;, then prefix the type names by Generator:: or Parser::
  • Create aliases for the namespaces or the types (C++11 only)

Repository owner locked and limited conversation to collaborators Sep 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants