Convert JSON to dot notation

Does anyone know a simple way to convert a Web Services JSON “result” to dot notation when the key values are unknown in a “Test Case”?

please define what is a ‘dot notation’
never heard about such

Using the example here:

String jsonString = ‘’'{“menu”: {
“id”: “file”,
“tools”: {
“actions”: [
{“id”: “new”, “title”: “New File”},
{“id”: “open”, “title”: “Open File”},
{“id”: “close”, “title”: “Close File”}
],
“errors”:[ ]

Something like this::

menu.id.file
menu.tools.actions.id.“new”.title.“New File”
menu.tools.actions.id.“title”.“Open File”
menu.tools.actionjs.id.“close”.title.“Close File”
menu.errors.[ ]

That is what my team was asking for.

Ok, you need to parse the json actually.
here the docs:
The Apache Groovy programming language - Parsing and producing JSON.

In Groovy/Java (=Katalon Studio), it would not be as simple as you wish.

There seems to be some “simple ways” in JavaScript/Node to flatten JSON.

Especially, the following Node package seems to be what you want:

Needless to say, the easiest way to run Node is to execute a command in shell :slight_smile:

$ node myscript.js mydata.json

where mydata.json is a JSON file to flatten, myscript.js is a JavaScript code you write.


If I were to flatten a Web Serivce JSON result with “node” + “flat” in Katalon Studio, I would do

  1. save the JSON into a local file
  2. in a Test Case(Groovy), invoke “node” command in command line while specifying a *.js file I write with the json file as param.

As for executing OS command from Katalon Test Case, see

or my “subprocessj” project may help

I have made a demostration of my idea. See my post here: