Comments (4)
How to represent date in Json Schema?
Using the keyword type
as string
and the format
keyword as date-time
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"$id": "https://github.com/NordicSemiconductor/lwm2m-types-js/blob/saga/LwM2MDocument.schema.json",
"title": "LwM2M JSON Schema",
"description": "JSON schema for expressing LwM2M resources as JSON",
"properties": {
"6": {
"properties": {
"5": {
"type": "string",
"format": "date-time",
"title": "Timestamp",
},
},
},
},
}
What is the expected value according to LwM2M XML definition?
2 examples:
<Item ID="5">
<Name>Timestamp</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Mandatory</Mandatory>
<Type>Time</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description><![CDATA[The timestamp of when the location measurement was performed.]]></Description>
</Item>
<Item ID="5518">
<Name>Timestamp</Name>
<Operations>R</Operations>
<MultipleInstances>Single</MultipleInstances>
<Mandatory>Optional</Mandatory>
<Type>Time</Type>
<RangeEnumeration></RangeEnumeration>
<Units></Units>
<Description>The timestamp of when the measurement was performed.</Description>
</Item>
What is the LwM2M definition of Time type ?
Unix Time. A signed integer representing the number of seconds since Jan 1st, 1970 in the UTC time zone.
How does the provided value look like in the shadow?
Object 3303 prop 5518: Temperature
{
"Timestamp": "2022-10-07T13:33:22Z"
}
Object 6, prop 5: Location
{
"Timestamp": "1970-01-01T00:00:00Z",
}
Problem
The expected format according to the standard is UNIX TIME
but provided value in shadow follows ISO 8601 date-time
from lwm2m-types-js.
How to represent UNIX TIME in Json Schema ?
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"$id": "https://github.com/NordicSemiconductor/lwm2m-types-js/blob/saga/LwM2MDocument.schema.json",
"title": "LwM2M JSON Schema",
"description": "JSON schema for expressing LwM2M resources as JSON",
"properties": {
"6": {
"properties": {
"5": {
"type": "integer",
"minimum": -864e12,
"maximum": 864e12,
"title": "Timestamp",
},
},
},
},
}
Because UNIX TIME definition says: it is the number of seconds between a particular date and the Unix Epoch
unixtimestamp
Other alternative could be add format
keyword as date-time
in object definition
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"$id": "https://github.com/NordicSemiconductor/lwm2m-types-js/blob/saga/LwM2MDocument.schema.json",
"title": "LwM2M JSON Schema",
"description": "JSON schema for expressing LwM2M resources as JSON",
"properties": {
"6": {
"properties": {
"5": {
"type": "integer",
"minimum": -864e12,
"maximum": 864e12,
"title": "Timestamp",
"format": "date-time",
},
},
},
},
}
However, this is not a real solution because "format": "date-time" only work on string type and LwM2M described value as integer:
here is described another alternative using ajv
, however that does not work neither because the expected value is UNIX TIME
format and not ISO 8601
format.
from lwm2m-types-js.
🎉 This issue has been resolved in version 2.1.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
from lwm2m-types-js.
How does the provided value look like in the shadow?
This is not relevant for this project.
from lwm2m-types-js.
Related Issues (9)
- Use fluent-json-schema to generate schema from LwM2M object definition HOT 1
- Remove unneccessary path from tsconfig
- Update from LwM2M registry fails
- Questions Record
- Update readme with steps to installation HOT 1
- Current range of Date type do not support valid dates HOT 7
- Dependency Dashboard
- Bug: resources defined as multiple instances are not defined as array type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lwm2m-types-js.