By default Z letter appending to date in tojson() format.

By default  Z letter appending to date in tojson() format. Please find below tojson() format output....

 

Output:

{"startDate:2019-01-02Z","endDate:2019-01-07Z"}

  Discussion posts and replies are publicly visible

  • +1
    Certified Lead Developer

    Hi  

    You can use the following approach if you want to avoid appending (means, zero hour offset) character at the end of a Date while converting it into a JSON (Text) format.

    a!toJson(
      {
        startDate: text(today(), "yyyy-mm-dd"),
        endDateTime: text(now(), "yyyy-mm-dd hh:MM:ss a")
      }
    )

    However, unless it's not business critical requirement for you, i wouldn't recommend you to remove Z offset from a Date.

    Hope this will help you.

  • Hi, 

    I don't understand because the norm ISO 8601 (ISO 8601 - Wikipedia) specify the Z for hours. If we have to set a birth date for exemple, we just need YYYY-MM-DD without the Z :

    Date 1973-01-11

    And if we have complex objects, we expect the a!tojson to return the date without the Z for date attributes automatically.

    With the workaround described, we must map attributes one by one.

    Exemple of complex object (CDT) - birthDate attribute has an appian date format in the CDT :

    a!localVariables(
    local!test: 'type!{urn:com:appian:types:cmr}cmr_api_people'(
    techPersonId: 1,
    person: {
    salutation: "MMe",
    firstname: "TEST",
    birthDate: now(),
    }
    ),
    a!tojson(local!test)
    )

    returns "{"techPersonId":1,"person":{"salutation":"MMe","surname":"","firstName":"","customaryName":"","birthName":"","birthDate":"2023-01-11Z","birthCounty":"","birthCountry":"","birthPlace":"","entityName":"","legalPersonalityCode":"","roleType":""},"socialSecurityNumber":"","nationality":"","fiscalResidenceStatus":""}"

    or we expert automatic mapping to (without Z) : 

    "{"techPersonId":1,"person":{"salutation":"MMe","surname":"","firstName":"","customaryName":"","birthName":"","birthDate":"2023-01-11","birthCounty":"","birthCountry":"","birthPlace":"","entityName":"","legalPersonalityCode":"","roleType":""},"socialSecurityNumber":"","nationality":"","fiscalResidenceStatus":""}"

    Regards