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

JSON variable file support #4532

Closed
Xdomen opened this issue Nov 11, 2022 · 7 comments · Fixed by #4542
Closed

JSON variable file support #4532

Xdomen opened this issue Nov 11, 2022 · 7 comments · Fixed by #4542
Labels
Milestone

Comments

@Xdomen
Copy link

Xdomen commented Nov 11, 2022

Problem

robot --variablefile burek.json -i smoke ROBOT/ returns the following error:
failed: Importing variable file ’burek.json’ failed: Not a valid file or directory to import.

while burek.py containing the same JSON content seem to work just fine.

--variablefile (-V) only seems to support Python and YAML file types.
We would like to use JSON file as a variablefile to pass on certain variables that are used by other frameworks as well.

Thanks for all the help!

@pekkaklarck
Copy link
Member

Adding support for JSON variable files wouldn't be too complicated. It would have a benefit that Python has a built-in json module but using YAML requires installing PyYYAML. I can add this to RF 6.1 scope and we can see is someone interested to look at it.

The reason I don't consider this super important is that you can already now pretty easily use JSON files as variable files. You can, for example, create a generic Python variable file that loads the JSON file. My understanding is that can also losslessly convert between JSON and YAML, so you could convert your JSON file to YAML before running Robot. It could even possible that just renaming your burek.yaml to burek.json would work. Anyway, being able to use JSON variable files directly and without installing PyYAML would be handy.

@pekkaklarck pekkaklarck changed the title Unable to pass JSON file as a variablefile JSON variable file suppport Nov 12, 2022
@pekkaklarck pekkaklarck added this to the v6.1 milestone Nov 16, 2022
@sunday2
Copy link
Contributor

sunday2 commented Nov 19, 2022

Is anyone working on this.

sunday2 added a commit to sunday2/robotframework that referenced this issue Nov 22, 2022
sunday2 added a commit to sunday2/robotframework that referenced this issue Nov 22, 2022
@mkorpela mkorpela changed the title JSON variable file suppport JSON variable file support Jan 11, 2023
@pekkaklarck
Copy link
Member

Thanks for a great PR @sunday2! Sorry for the review taking so long. There were few simple changes to be done to code and tests. I hope you can take a look at them, but I can also merge the PR as-is and make changes myself. Another thing to do is writing documentation.

sunday2 added a commit to sunday2/robotframework that referenced this issue Mar 4, 2023
@sunday2
Copy link
Contributor

sunday2 commented Mar 6, 2023

Thanks for a great PR @sunday2! Sorry for the review taking so long. There were few simple changes to be done to code and tests. I hope you can take a look at them, but I can also merge the PR as-is and make changes myself. Another thing to do is writing documentation.

Thank you for the review and all the comments, I have updated the code and pls help review again.

pekkaklarck pushed a commit that referenced this issue Mar 10, 2023
Implements #4532. Documentation still missing.
@pekkaklarck pekkaklarck added the acknowledge To be acknowledged in release notes label Mar 10, 2023
@pekkaklarck
Copy link
Member

Thanks again for a great and now finally merged PR @sunday2! I wrote documentation for this feature (see commit f7ee913) so we can consider this issue done.

@pekkaklarck
Copy link
Member

pekkaklarck commented Mar 10, 2023

If you want to see how the documentation actually looks, you can generate the User Guide locally with this command:

doc/userguide/ug2html.py create

If you see a typo or have enhancement ideas, just comment here or create another PR.

@sunday2
Copy link
Contributor

sunday2 commented Mar 11, 2023

If you want to see how the documentation actually looks, you can generate the User Guide locally with this command:

doc/userguide/ug2html.py create

If you see a typo or have enhancement ideas, just comment here or create another PR.

Thank you for the help, that's helpful.

yanne pushed a commit that referenced this issue Mar 18, 2023
Implements #4532. Documentation still missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants