What is JSON?
JavaScript Object Notation, more commonly known by the acronym JSON, is an open data interchange format that is both human and machine-readable. Despite the name JavaScript Object Notation, JSON is independent of any programming language and is a common API output in a wide variety of applications.
What is cucumber data table?
A data table (or data matrix) is a special type of table that allows us to compare a set of numerical values simultaneously easily. It’s great for displaying data that you would like people to understand at a glance.
They are used for displaying numbers and statistics. Still, they can also be used as a simple way of providing information about a range of choices and doing multiple tests for a particular scenario, as we will use today.
Concept:
The purpose of this component is to take JSON as input and return it as a data table.
Parameters:
- jsonString* – to provide the JSON as input to extract as output.
- prefixPadding* – The padding space for the key column(left) in table data
- replacableStrings – To mention strings in a comma-separated list that needs to be replaced as an empty string. Example:ObjectId(,NumberLong(,JUUID(,),$
- suffixPadding* – The padding space for the value column(right) in table data
(*)Mandatory
Run the application:
- Find the jar here https://github.com/Ashwin-9227/cucumber-data-generator-runnable-file
- Download the jar by name cucumberdatatablegenerator-0.0.1-SNAPSHOT.jar
- Place it in any folder that is accessible.
- Open a command prompt and go to the appropriate destination.
- If the location of the jar is in the folder is D:\xxx\yyy
- Open command prompt, input: D:(press enter)
- You will be in D:\ input: cd D:\xxx\yyy
- Now you will be in D:\xxx\yyy
- Execute the jar by using the following command. Input: java -jar cucumberdatatablegenerator-0.0.1-SNAPSHOT.jar
- If you see similar to Started CucumberDataTableGeneratorApplication in 4.945 seconds (JVM running for 5.717). Then your application has started successfully.
URL to open the application
An example of how it works:
- Open the URL which is provided above.
- Navigate to the path as provided here.
- In the jsonString body paste in the needed JSON formatted data that you need to convert into a cucumber data table.
- Add the padding parameters to format the data table output
- Click on execute.
- Voila! now you have successfully converted JSON data in cucumber’s data table using this simple generator tool
This tool is the initial version where you might come across some errors while running. Try adding the unrecognized JSON parameter in replacableStrings and check it works. If it doesn’t feel free to reach me for suggestions.