Forum Discussion

andrewsaunders's avatar
andrewsaunders
Occasional Contributor
9 years ago

json object

 hi

 

i'm working with REST and JSON payloads and have had some difficulty with soapUI when i attempt to dynamically generate a JSON object from a spreadsheet -

 

it may be my solution - where an indicator resolves to true then my script will proceed to iterate over as many rows as are identified for a request message. Each row represents an item to be added to a JSON array. I've noticed that as I added items to the array and the fitted that array into an object - before my script moed onto the next row, using the datasource/datasource loop, the object could not be retained nor saved to a test case/test suite property. I was forced to save it as a string and re-read as a string up on the next loop - remove the comment characters and convert back to a json object.

 

is there anyway that SOAPui could retrain objects in memory created by a groovy script? 

3 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Can you please add more details like how the test case structure or steps involved and what is the hurdle? or the Use case?
    • andrewsaunders's avatar
      andrewsaunders
      Occasional Contributor

      hi rao

       

      sorry for the late reply - i don't recall getting a notification via email that this post was replied to.

       

      I don't think the detail for what i'm specifically trying to achieve is important.

       

      What I'm really asking is, whilst using the groovy script test step - is there a way to store an object within ready during runtime? There appears to be a feature named 'context.myproperty' that aims to achieve this but when I attempted this the object when called was slightly distorted for an xml object or json object - seems ready couldn't store it as it was passed and corrupted it...

       

      do you have any further insight into how i may store an object created within a groovy test step for later use in a test case? The alternative is for me to write and compile a class to achieve this but then I begin to move a lot of the work outside the context of ready api.

       

      thanks

      Andy

      • nmrao's avatar
        nmrao
        Champion Level 3

        You should be able to subscribe for update notifications from the preferences, I believe. Otherwise need to look for updates in the forum. It's user choice.

        Unless there is enough information, it would be difficult to suggest any.

        Like you mentioned, I too read somewhere in the posts, but never tried.
        From your response, it appears that you already tried. So, can you just add details about the script you tried (code snippets - how you set, where you trying into get, in the same script, or other test steps, running a test case or just tried with single step) and actual output and expected output will help people to answer better.