Invalid character after object key - What is an object key in geojson?

makansij picture makansij · Jul 18, 2015 · Viewed 19.8k times · Source

I am importing the following text file to geojson:

{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{type":"LineString","coordinates":[[-122.029517,37.976152]]},"properties":{"name":"thing","origin":"somewhere","end":"blah"}}]}

mongoimport -vvv --db <db> --collection <collection-name> --file <file-name>

The long verbose output is :

<Date, etc> -0700   using 4 decoding workers
<Date, etc> -0700   using 1 insert workers
<Date, etc> -0700   filesize: 921 bytes
<Date, etc> -0700   using fields: 
<Date, etc> -0700   connected to: localhost
<Date, etc> -0700   ns: <db>.<collection>
<Date, etc> -0700   connected to node type: standalone
<Date, etc> -0700   standalone server: setting write concern w to 1
<Date, etc> -0700   using write concern: w='1', j=false, fsync=false, wtimeout=0
<Date, etc> -0700   Failed: error processing document #1: invalid character '"' after object key
<Date, etc> -0700   standalone server: setting write concern w to 1
<Date, etc> -0700   using write concern: w='1', j=false, fsync=false, wtimeout=0
<Date, etc> -0700   imported 0 documents

As you can see, the error is invalid character '"' after object key. The quotes are necessary, however. Is there an easy fix for this?

Answer

Ned Rockson picture Ned Rockson · Jul 18, 2015

It appears the third instance of the word type is not properly quoted. If you add a double quote prior to that word you should be able to import without any issues.