I have a similar question as I'm considering architecting my solution
to write the serialized BSON (via BsonDocument.ToJson()) to a web
page.
Of course, the problem with this is that it produces the
ISODate("...") and ObjectId("...") as a part of the JSON response,
which obviously has no implementation on the client and causes an
error.
So I wonder if there is a default script file that contains an
implementation of these functions somewhere that can be included in
the page? Is there an alternative way to serialize the objects to a
JSON string that will produce an object without these function calls?
I've tried the JavaScriptSerializer from
System.Web.Script.Serialization. The problem with this approach is
that it does not include the type discriminator for inherited types
whereas BsonDocument.ToJson() does include this as (by default) a
field "_t".
Other thoughts on the proper way to server the JSON to the browser in
a way that can be processed by the client runtime?
On Jun 2, 9:55 pm, Bernie Hackett <
ber...@10gen.com> wrote:
> Why not just run the command "replSetGetStatus" using the command
> method of the Database class in Ruby? NoJSON.parse required. All the
> mongo shell does is run that command:
>
> repl0:PRIMARY> rs.status
> function () {
> return db._adminCommand("replSetGetStatus");
>
> }
>
> On Jun 2, 4:35 pm, Gunners <
naren.chain...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Here is a quick overview of what we have set-up..
>
> > We have a script written in ruby, which periodically does the
> > following two things on the primary node.
> > resp = `mongo --quiet --eval 'printjson(rs.status())'`
> >JSON.parse(resp)
>
> > This response is then used for logs and few other things.. This script
> > recently stopped working when we transitioned from mongo 1.6.5 to
> > 1.8.1.. Turns out that with 1.8.1, the response of
> > printjson(rs.status()) call was not purejsonbut contained dates in
> > the format ofISODate("xxxxxx")... Thus the call toJSON.parse