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

  • williammccuskerwilliammccusker Posts: 432 ✭✭

    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?

  • williammccuskerwilliammccusker Posts: 432 ✭✭

    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.

  • williammccuskerwilliammccusker Posts: 432 ✭✭

    Glad I could help!

Sign In or Register to comment.