runner36 / rock-php

Automatically exported from code.google.com/p/rock-php
0 stars 0 forks source link

uncaught exception: field names cannot start with $ [$binary] when importing json #241

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1.Use a document with this format:
o={         "_class" : 
"net.ulala.bla.spi.impl.mongodb.catalogue.BrandSpringDataMongoDbImpl",         
"_id" : {                 "$binary" : "AItjb4a9RXCDHNeX+lWtAQ==",               
  "$type" : "04"         },         "dateAdded" : {                 "$date" : 
1143759600000         }}

{
        "_class" : "net.ulala.bla.spi.impl.mongodb.catalogue.BrandSpringDataMongoDbImpl",
        "_id" : {
                "$binary" : "AItjb4a9RXCDHNeX+lWtAQ==",
                "$type" : "04"
        },
        "dateAdded" : {
                "$date" : 1143759600000
        }
}

2.Try to insert it/use import feature to put it into the database

3.You will get an error like this:
uncaught exception: field names cannot start with $ [$binary]

The data is correct and it should be imported. In fact the dump was created 
with mongoexport and successfully imported if you mongoimport. 

The types used are explained here:

http://docs.mongodb.org/manual/reference/mongodb-extended-json/

If I add them in this format(mongo Shell Mode):

 b={ "_class": "net.ulala.bla.spi.impl.mongodb.catalogue.BrandSpringDataMongoDbImpl",  "_id" : BinData ( "04","AItjb4a9RXCDHNeX+lWtAQ==" ),  "dateAdded" : new Date('1143759600000') } 

The data is imported ok .

RockMongo Version 

Web server  Apache/2.2.3
PHP version     PHP 5.3.23(tried various versions)
PHP extension   mongo/1.3.6(tried older version too)
OS              Centos

Rock Mongo  1.1.5

MongoDB version (2.2, 2.4.1)

Please provide any additional information below.

These are the command ran manually via command line wher eyou can see the same 
problem:

> b={ "_class": 
"net.ulala.bla.spi.impl.mongodb.catalogue.BrandSpringDataMongoDbImpl",  "_id" : 
BinData ( "04","AItjb4a9RXCDHNeX+lWtAQ==" ),  "dateAdded" : new 
Date('1143759600000') }
{
        "_class" : "net.ulala.bla.spi.impl.mongodb.catalogue.BrandSpringDataMongoDbImpl",
        "_id" : BinData(4,"AItjb4a9RXCDHNeX+lWtAQ=="),
        "dateAdded" : ISODate("0NaN-NaN-NaNTNaN:NaN:NaNZ")
}
> db.brands.insert(b);
> o={         "_class" : 
"net.ulala.bla.spi.impl.mongodb.catalogue.BrandSpringDataMongoDbImpl",         
"_id" : {                 "$binary" : "AItjb4a9RXCDHNeX+lWtAQ==",               
  "$type" : "04"         },         "dateAdded" : {                 "$date" : 
1143759600000         }}
{
        "_class" : "net.ulala.bla.spi.impl.mongodb.catalogue.BrandSpringDataMongoDbImpl",
        "_id" : {
                "$binary" : "AItjb4a9RXCDHNeX+lWtAQ==",
                "$type" : "04"
        },
        "dateAdded" : {
                "$date" : 1143759600000
        }
}
> db.brands.insert(o);
Thu Mar 28 16:39:54 uncaught exception: field names cannot start with $ 
[$binary]
>

Original issue reported on code.google.com by stan.ion...@gmail.com on 28 Mar 2013 at 4:59