Casting dates to and from JSON

Hi,

So when Appian writes dates to Json, it cannot cast those values correctly if it reads them back.

load(
  local!data:{
    today()
  },
  local!jsonData: a!toJson(
    local!data
  ),
  local!fromJson: cast(
    typeof(today()),
    a!fromJson(
      local!jsonData
    )
  ),  
  a!sectionLayout(
    contents: {
      a!textField(
        value: local!jsonData
      ),
      a!textField(
        value: local!fromJson
      )
    }
  )
)

Do I have to manually alter the string in order to reorder the date from "YYYY-MM-DDZ" to "DD-MM-YYYYZ" before I run from Json?

Is there a reason that Appian designed it this way?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    over 4 years ago
    Hello,

    I have to say that passing the dates as integer is easier than handling it as strings.

    tointeger(today())
    The drawback is that you have to cast it back to date( but that is something you are already doing as string in the code you shared)

    Hope this helps

    Jose
Reply
  • 0
    Certified Lead Developer
    over 4 years ago
    Hello,

    I have to say that passing the dates as integer is easier than handling it as strings.

    tointeger(today())
    The drawback is that you have to cast it back to date( but that is something you are already doing as string in the code you shared)

    Hope this helps

    Jose
Children