Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D587CBE4E for ; Tue, 10 Jan 2012 10:27:50 +0000 (UTC) Received: (qmail 60515 invoked by uid 500); 10 Jan 2012 10:13:13 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 60357 invoked by uid 500); 10 Jan 2012 10:12:57 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 60311 invoked by uid 99); 10 Jan 2012 10:12:54 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jan 2012 10:12:54 +0000 Received: from localhost (HELO mail-iy0-f180.google.com) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jan 2012 10:12:53 +0000 Received: by iadk27 with SMTP id k27so790240iad.11 for ; Tue, 10 Jan 2012 02:12:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.50.180.138 with SMTP id do10mr1839099igc.20.1326190372751; Tue, 10 Jan 2012 02:12:52 -0800 (PST) Received: by 10.42.243.67 with HTTP; Tue, 10 Jan 2012 02:12:52 -0800 (PST) In-Reply-To: References: Date: Tue, 10 Jan 2012 10:12:52 +0000 Message-ID: Subject: Re: i have a bulk insert problem about invalid json From: Robert Newson To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable ufeff is a BOM, yes, good catch. On 10 January 2012 09:29, Jason Smith wrote: > When CouchDB says ""invalid UTF-8 JSON" that could mean one of two things= : > > 1. Invalid UTF-8 > 2. Invalid JSON > > In your case, perhaps your text file has the byte order mark in it > > =A0 =A0http://en.wikipedia.org/wiki/Byte_order_mark > > The article says many Windows programs (including Notepad) add this to > text files by default. Perhaps use a different editor, or discover how > to disable this mark (which is invalid JSON I guess) and make a new > file. > > On Tue, Jan 10, 2012 at 4:11 PM, Zekeriya KO=C7 wrot= e: >> Sorry for subjectless message!!! >> >> Hello, >> >> my problem: i am trying to insert approximately 255000 documents to a >> >> couchdb instance with bulk docs api. i always get invalid json >> error. >> >> so i am trying to test =A0the problem with just one document. because >> the error raises wether with a large file or a file with just one >> document. >> >> my system: >> couchdb: on an ubuntu server 10.04 >> client: windows 7 with cygwin curl >> >> $ curl -X GET http://admin:ad... >> @10.81.2.100:5984 >> {"couchdb":"Welcome","version":"1.1.0","vendor": >> {"version":"1.2.0","name":"Couchbase","url":"http:// >> www.couchbase.com/ >> "}} >> >> $ curl -d @test.txt -H "Content-Type:application/json" -X POST >> http://admin:ad... >> @10.81.2.100:5984/dbmerkez/_bulk_docs >> {"error":"bad_request","reason":"invalid UTF-8 JSON: <<\"\ufeff{\\ >> \"docs\\\":[{\\\"adi\\\": \\\"zeko\\\"}]}\">>"} >> >> now i copy the content of test.txt and paste it to my command line: >> $ curl -d '{"docs":[{"adi": "zeko"}]}' -H "Content-Type:application/ >> json" -X POST http://admin:ad... >> @10.81.2.100:5984/dbmerkez/_bulk_docs >> [{"id":"74a5d37e71215e2095d00f90a00007ac","rev":"1-111c10804ee9f2b8384ab= 95e >> f66268e0"}] >> >> as you can see same content gives an invalid json error within a file >> but from direct command line it inserts fine. >> >> my text file is encoded in utf-8. >> >> i am so close to give up. i am fighting with this for hours. if i can >> not insert initial data to my instance i can not test the replication >> cases. >> >> please help!! >> >> -- >> Zekeriya "zekUs" KO=C7 - http://zekzekus.com/ >> >> >> >> -- >> Zekeriya "zekUs" KO=C7 - http://zekzekus.com/ > > > > -- > Iris Couch