Service Virtualization

 View Only
  • 1.  Current date time in Json body Response

    Posted Jun 21, 2019 11:03 AM
    A sample of my current json response (body text)  is:

    "account": [
    {
    "accountStatus": "ACTIVE",
    "refreshinfo": {
    "lastRefreshed": "2019-05-15T03:34:15Z",
    "statusMessage": "OK"
    }
    }
    ]
    }

    I need to set the value of the lastResreshed element as current Date time.

    When I try to set the value of this element to:

    "lastRefreshed": "{{=doDateDeltaFromCurrent("yyyy-MM-dd'T'HH:mm:ss'Z'","0D");/*2019-06-17T15:14:40Z*/}}",

    I get the error:  missing } after property list.

    What is the current syntax to get the current date time value?

    Will appreciate response/help.

    Thanks

    Kishore

    ------------------------------
    SV Architect
    US Bank
    USA
    ------------------------------


  • 2.  RE: Current date time in Json body Response
    Best Answer

    Posted Jun 21, 2019 02:47 PM
    Instead, if you use timestamp filter and store value in one property say current Time and use same property in your JSON, it should work

    ------------------------------
    Sabir
    ------------------------------



  • 3.  RE: Current date time in Json body Response

    Posted Jun 21, 2019 04:02 PM
    Thanks.  This solution worked!

    ------------------------------
    SV Architect
    US Bank
    USA
    ------------------------------



  • 4.  RE: Current date time in Json body Response

    Posted Jun 24, 2019 07:49 AM

    Hi Kishore,

     

    So you used  a work-around and it solved your problem so that's good.

     

    I just wanted to remark that the error message "missing } after property list" is an error message inside the VSIs image editor. And this is because the double quotes inside the magic date expression mess up the JSON syntax. But it does work at runtime! This is because the parsing of magic strings and magic date just treats the response as a block of text when substituting, so your "{{=doDateDeltaFromCurrent("yyyy-MM-dd'T'HH:mm:ss'Z'","0D"); }}" gets properly replaced with a timestamp value, and the response becomes correct JSON again when it gets sent as a response to the client.

     

    Cheers,

    Danny

     

    ::DISCLAIMER::
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects.
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------