JSON Template Date Issue

Submitted by ausathya on Tue, 2009-05-26 10:00.Troubleshooting

Hello there,
I am beginner with dbsight. I am trying to use the JSON as a mechanism to query and get back results between my application and dbsight server.
I am having difficulty with Date.
I end up getting the JSON string as
callback("items":[{"I_DATE":Sat Feb 07 00:00:00 EST 2009}])
instead of
callback("items":[{"I_DATE":"Sat Feb 07 00:00:00 EST 2009"}])
notice the missing quotes.
Appreciate help fixing this.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Submitted by chris on Tue, 2009-05-26 10:24.

This string representation is the default behavior of org.json.simple.JSONObject. Javascript does not have a standard way to represent date object.

Would it be good to just use "long" integer to represent the date?

I have just updated the latest beta release(build 419) with this change. So now the date by default is represented as a long number now.

Instead of the previously default:

 <#assign dummy = item.put("created_at", doc.getObject("created_at"))>

You can also directly adjust the date format in documents.ftl of your template via

 <#assign dummy = item.put("created_at", doc.getDate("created_at")?string("yyyy-MM-dd HH:mm:ss zzzz"))>

Check this page for details on how to format date in freemarker: http://freemarker.sourceforge.net/docs/ref_builtins_date.html

Submitted by ausathya on Tue, 2009-06-02 08:44.


doc.getDate("created_at")?string("yyyy-MM-dd HH:mm:ss zzzz")

worked for me.