Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am creating a workflow to extract the json string from spark job in the tSystem using tJava:
tSystem -> tJava
Expected output is, firstly, tSystem will give the string result in the form of log.info() and also in json format. Later, tJava will extract and only print out the json string while ignore the other string format.
Spark output from tSystem:
String output=((String)globalMap.get("tSystem_3_OUTPUT"));
JSONObject jsonObject = new JSONObject(output);
System.out.println(jsonObject);
String sourceCount=(jsonObject.getString("Source rows"));
System.out.println("Database Name: "+jsonObject.getString("DBName"));
globalMap.put("sourceCount",sourceCount.trim());
However, when I run my current workflow, the following error appears which I believe is because my java code in tJava tried to read the string in all format , instead of json string only.
Error in tJava:
FATAL] 11:18:46 nerve_ingestion.fullrefreshingestion_dev_0_15.FullRefreshIngestion_Dev- tJava_3 A JSONObject text must begin with '{' at 1 [character 2 line 1]
routines.system.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
at routines.system.JSONTokener.syntaxError(JSONObject.java:1790) ~[routines.jar:?]
at routines.system.JSONObject.<init>(JSONObject.java:166) ~[routines.jar:?]
at routines.system.JSONObject.<init>(JSONObject.java:279) ~[routines.jar:?]
How should i change the java code to ensure tJava only capture the json string?
Hi jzhao,
Issue solved. Basically I did following step in tJava:
Thanks for responding!
Hello,
what's the content of "output" ?
Hi jzhao,
Issue solved. Basically I did following step in tJava:
Thanks for responding!