SocketCluster / SocketCluster/socketcluster-client
Option to decode JSON date string
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 300
- Forks
- 90
- PR merge metrics
- No merged PRs in 30d
Description
When sending Date objects, they are serialized into ISO string format, and JSON parse doesn't convert them back.
Propose to add option to JSON decode function, for example
const dateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
function dateReviver(key, value) {
if (typeof value === "string" && dateFormat.test(value)) {
return new Date(value);
}
return value;
}
module.exports.decode = function(str) {
return JSON.parse(str, dateReviver)
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the JSON decode function described in the issue and inspect how the client currently parses incoming strings. Define and implement the requested opt-in date decoding behavior, then add or update coverage for ISO date strings and ordinary string values so the option's effect is clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100