Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Is there a way to import JSONObject in Groovy

I need to convert string to json object using Groovy. But when I try to add the statement
import org.json.simple.JSONObject
I get the compiler error saying unable to resolve the class.
Please provide some guidance.

Tagged:

Comments

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,

    Is that class provided by a jar file that has been added to System Properties in the preferences? Groovy has it's own json parsing library that might work for what you need

    https://groovy-lang.org/json.html

  • Thanks for the response. The Groovy json library did work for me.

    I did not added the JSONObject jar file to the system properties.
    But if I add the jar file on my local, while promoting the code to different servers/environments do I need to add the jar file there?

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,
    Yes if you added the jar file and used it locally you would need to add that jar file to remove servers. If the groovy json library works for you that would be the better option for deploying into multiple remote environments since it won't require additional changes to the servers.

  • Thank you so much for the explanation.

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Glad I could help!