[SERVER-1941] serverStatus Date() is not JSON, therefore it is not JSON parsable Created: 13/Oct/10  Updated: 12/Jul/16  Resolved: 15/Nov/10

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.6.3
Fix Version/s: 1.7.3

Type: Bug Priority: Minor - P4
Reporter: Merlin Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

While creating a collector for graphing in ZenOSS using the serverStatus?text url, it was found that the resulting output is merely JSON-like and not actually JSON.

{ "version" : "1.6.3",
"uptime" : 4712,
"uptimeEstimate" : 3844,
"localTime" : Date( "Wed Oct 13 20:52:15 2010" ),
...

Python's simplejson and json modules cannot load this due to the Date( "" ) which is not valid JSON. However, simplejson DOES support ISO datetimes, as per one of the answers found here: http://stackoverflow.com/questions/455580/json-datetime-between-python-and-javascript .

So, either the date needs to be returned as an ISO datetime string, or it needs to become an actual object like:

{"localTime":

{ "date" : "Wed Oct 13 20:52:15 2010" ) }

}

Otherwise, to parse this in Python, one has to manually remove the Date( ) wrapper around the string, which I am doing for now, but would like to not do.



 Comments   
Comment by Mathias Stearn [ 15/Nov/10 ]

Fixed now, but I'd still recommend using _status.

Comment by auto [ 15/Nov/10 ]

Author:

{'login': 'RedBeard0531', 'name': 'Mathias Stearn', 'email': 'mathias@10gen.com'}

Message: Use strict JSON for commands SERVER-1941
/mongodb/mongo/commit/b717404a1aca89d6dd75fc9c8c3f08277b4c19cb

Comment by Mathias Stearn [ 15/Nov/10 ]

I would suggest using /_status rather than /serverStatus since the former uses strict json and is always available even if you dont run with --rest. I'm looking into why /serverStatus isn't using strict json now.

Comment by Eliot Horowitz (Inactive) [ 12/Nov/10 ]

Can you make it use the same format you use in shell

Comment by Merlin [ 13/Oct/10 ]

Errr, apologies for the broken example of the JSON object (can't find an edit button in JIRA):

{"localTime":

{ "date" : "Wed Oct 13 20:52:15 2010" }

}

Generated at Thu Feb 08 02:58:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.