primitive type representation

Feb 17, 2011 at 1:46 PM

Hi,

how are values of primitive types presented? Because there are two different representations depending on what response you get: JSON or Atom format.

I guess datajs uses a consistent representation format regardless if using ATOM or JSON.

Do you use the representation like described here:

http://www.odata.org/developers/protocols/overview#AbstractTypeSystem

?

Ok, what I checked so far for example is that with v0.0.2 you now get a Javascript date object wheras with v.0.0.1 you got

JSON : "/Date(1282379236000)/"

ATOM:  2010-08-21T08:27:16Z

as it was described in the corresponding oData spec for JSON/ATOM.

So the question is which format do you use for the other primitive types? The Atom representation format?

http://www.odata.org/developers/protocols/atom-format#PrimitiveTypes

Thanks

Feb 17, 2011 at 4:38 PM

Hi Ironmanager,

Thank you for trying v0.0.2 so quickly :).  Indeed, for that version now properties of type Edm.DateTime and Edm.DateTimeOffset are converted to JS Date objects; Marcelo has blogged about this change.

As for the rest of the primitive types we align to the JSON representation.  The following table shows the mapping we do between Edm primitive types and JavaScript data types:

Primitive Type

JavaScript Data Type

Edm.Binary

String

Edm.Boolean

Boolean

Edm.Byte

Number

Edm.DateTime

Date

Edm.DateTimeOffset

Date

Edm.Decimal

String

Edm.Double

Number

Edm.Guid

String

Edm.Int16

Number

Edm.Int32

Number

Edm.Int64

String

Edm.SByte

Number

Edm.Single

Number

Edm.String

String

Edm.Time

Not Supported

Thanks,

Alex Trigo.