Hey Guys
I was wondering if any of you could answer this question.So I have String variable, which is in format of JSON and I want to extract certain parameters from it.I'd like to write below java code as a keyword but Katalon wouldn't import json.* because the import is in java format.
How do I manage java imports in groovy file?
could you please advise? below is the code.
import org.json.*;public class JsonParameterExtractor { public void jsonExtractor(String response){ String json = response.getResponseText() JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject) parser.parse(json); String authenticationToken = (String) jsonObject.get("authenticationToken"); }}Thanks
Niro
Apologies for some reason this discussion been posted thrice.
Thanks
Niro
Hi Niro,
I can hardly see your script. This is an issue of our code formatting so we will plan to fix it, however for the time being please post your code without any formatting so that I can see it better.
Regards
By the way, you can press ‘Ctrl + Shift + O’ hotkeys to automatically fill in necessary import libraries instead of just using org.json.*
Please ensure to import external libraries first: https://docs.katalon.com/display/KD/External+Libraries
Many thanks for this guys,
I shall copy paste the code from now on.