Opened 14 years ago

Closed 14 years ago

#4970 closed defect (duplicate)

toJson doesn't handle primitive Date objects

Reported by: Adam Peller Owned by: Adam Peller
Priority: high Milestone: 1.1
Component: General Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by Adam Peller)

toJson(new Date()) yields "{}"

Change History (3)

comment:1 Changed 14 years ago by Dustin Machi

I also noticed last night it renders Data objects as {}, though i'm not sure what the appropriate behavior in this situation is, I would have minimally though it would have been a toString.

comment:2 Changed 14 years ago by Adam Peller

Description: modified (diff)
Summary: toJson doesn't handle primitive typestoJson doesn't handle primitive Date objects

I guess the primitive types are ok. It makes sense for a string to have the quotes inside it. But dmachi is right -- we need something to deal with Dates. If we're not going to use the registry, perhaps we create a special hook just for Date objects, since they're both special and commonly used in this context. Crockford just uses ISO Dates, I think.

comment:3 Changed 14 years ago by Adam Peller

Resolution: duplicate
Status: newclosed

dup of #5726

Note: See TracTickets for help on using tickets.