How toWeb Service Developer Guide

Web Service Developer Guide

Sana Commerce 8.2
Your provider

Date and Time in JSON

In the Sana Commerce web service there is a difference on how the DateTime data type in the filter is handled in the XML and JSON requests.
 
In the XML request the DateTime data type can be used in the following criteria:

  • EqualCriterion
  • BetweenCriterion
  • GreaterCriterion
  • LessCriterion

The DateTime data type cannot be used in the ContainsCriterion criterion type, that is why this criterion does not support the DateTime values.

In the JSON request the DateTime data type cannot be used in any of the abovementioned criteria. This is because the DateTime values are represented as strings in JSON (e.g. "\/Date(1325181367000)\/") and the Sana Commerce web service handles these values as of the String data type. Thus in the JSON request other types of criteria should be used, specially designed for handling the DateTime values:

  • EqualDateTimeCriterion (equals to EqualCriterion)
  • BetweenDateTimeCriterion (equals to BetweenCriterion)
  • GreaterDateTimeCriterion (equals to GreaterCriterion)
  • LessDateTimeCriterion (equals to LessCriterion)

Any of the [...]DateTimeCriterion criterion types can be used to filter the products on the field of DateTime data type using the JSON request.

Criterion type XML
EqualCriterion
<Criterion i:type="EqualCriterion">
  <Value i:type="a:dateTime" xmlns:a="http://www.w3.org/2001/XMLSchema">2011-12-29T17:56:07</Value>
  <Not>false</Not>
</Criterion>
ContainsCriterion
<Criterion i:type="ContainsCriterion">
  <Value i:type="a:dateTime" xmlns:a="http://www.w3.org/2001/XMLSchema">2011-12-29T17:56:07</Value>
  <Not>false</Not>
</Criterion>
GreaterCriterion
<Criterion i:type="GreaterCriterion">
  <Value i:type="a:dateTime" xmlns:a="http://www.w3.org/2001/XMLSchema">2011-12-29T17:56:07</Value>
  <StrictGreater>false</StrictGreater>
</Criterion>
LessCriterion
<Criterion i:type="LessCriterion">
  <Value i:type="a:dateTime" xmlns:a="http://www.w3.org/2001/XMLSchema">2011-12-29T17:56:07</Value>
  <StrictLess>false</StrictLess>
</Criterion>


Criterion type JSON
EqualDateTimeCriterion
{
"__type":"EqualDateTimeCriterion",
"Value":"\/Date(1325181367000)\/",
"Not":false
}
ContainsDateTimeCriterion
{
"__type":"ContainsDateTimeCriterion",
"Value":"\/Date(1325181367000)\/",
"Not":false
}
GreaterDateTimeCriterion
{
"__type":"GreaterDateTimeCriterion",
"Value":"\/Date(1325181367000)\/",
"StrictGreater":false
}
LessDateTimeCriterion
{
"__type":"LessDateTimeCriterion",
"Value":"\/Date(1325181367000)\/",
"StrictLess":false
}
How toWeb Service Developer Guide