• JSON REST and Datefields

    By Dieter C Haag 1 decade ago

    Hi,

    i'm using a xe:restService and i want to Post a new Document to a Database.

    <xe:restService id="restServiceDoc" pathInfo="/doc"

        preventDojoStore=&quot;true&quot;&gt;<br/>
        &lt;xe:this.service&gt;<br/>
            &lt;xe:documentJsonService defaultItems=&quot;true&quot;                <br/>
    

    compact="#{javascript:context.getUrlParameter('Compact')=='' || context.getUrlParameter('Compact')=='true' }"

                contentType=&quot;application/json&quot;<br/>
    

    formName="#{javascript:context.getUrlParameter('Form')}">

            &lt;/xe:documentJsonService&gt;<br/>
        &lt;/xe:this.service&gt;<br/>
    &lt;/xe:restService&gt;<br/>
    

    Now when i execute a dojo.xhrPost targeting my REST Service to my JSON:



    {"Body":"Body Text Content","Subject":"Test Entry","PostedDate":"2012-04-13T11:21:16Z","TargetDate":"2012-04-25T11:21:16Z"}



    The PostedDate will be converted to a NotesDatetime but the TargetDate won't.

    Is there a way to enforce a conversion, or better define the Type of a JSON Value when Posting it to the Server?



    Thanks in advance

    • Suggestion...

      By Stephen Auriemma 1 decade ago

      Try using:

       

          "TargetDate":
          {
              "data":"2012-04-25T11:21:16Z",
              "type":"datetime"
          },

      • Thanks

        By Dieter C Haag 1 decade ago

        it worked like a charm Lächelnd