Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Unable to compile org.json.JSONObject library

SA-54376

Summary



User is trying to convert Pega Clipboard page to JSON object to use in Connect-REST rule.

After converting Clipboard page in JSON Object, user is also removing pxObjClass using new function rule created using org.json.JSONObject.

They are able to generate the library and function in Developer environment, but the same is throwing an error in System integration testing (SIT) environment.


Error Messages



Error(s) detected while generating java. Compiler reported: ----------
 ERROR in com/pegarules/generated/test_RemoveElementFromJSON_010605_KpaCW2YJfeHfYTAhoa5FxQ.java (at line 103, line 109, line 110) , (at line 111), (at line 112), (at line 114), (at line 115),(at line 124)
org.json.JSONObject jo=new org.json.JSONObject(jsonSource);
^^^^^^^^^^^^^^^^^^^
org.json.JSONObject cannot be resolved to a type
----------

 


Steps to Reproduce



Generate the library having new function.


Root Cause



The jar related to org.json.JSONObject is missing in the environment.
 

Resolution



Make the following change to the operating environment:

Import the proper jar.
After importing the custom function is not working properly, then use the below function to remove pxobjclass:

json = json.replaceAll("\"" + prop + "\"[ ]*:[^,}\\]]*[,]?", "")

 

json is the string containing the json data and prop is the key that you want to remove. This works perfectly for a single valued key like pxobjclass.

Published July 23, 2018 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us