c# - MongoDB, trying to import json which has been serialized using TypeNameHandling.Objects -


i'm receiving error trying import json mongodb.

2016-01-15t14:57:09.682-0800 error inserting documents: document can't have $ prefixed field names: $type

the json serialized using json.net

 var settings = new jsonserializersettings(); settings.typenamehandling = typenamehandling.objects; string output = jsonconvert.serializeobject(o, formatting.indented, settings); 

see mongodb documentation talks restrictions on field names.

field names cannot contain dots (i.e. .) or null characters, , must  not start dollar sign (i.e. $). 

if using mongo shell import you'll have change $type else.

alternately, use c# driver import documents , handle serializing concrete type name automatically.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -