Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6615995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:31:47+00:00 2026-05-25T20:31:47+00:00

I use the following CouchDB design document for testing purposes. I use carriage return

  • 0

I use the following CouchDB design document for testing purposes. I use carriage return \n and tabs \t to indent my Javascript code. As far as I understand JSON, I think that whitespaces in those places are OK. But Ruby couchrest fails parsing that and JSLint too. I have to strip the \n and \t out of the design document before parsing it. Why is that ?

The JSON introduction page on json.org mentions that “Whitespace can be inserted between any pair of tokens. “

It is a little bit difficult to render tabs here so I have included a parsed string with \n and \t.

{
"_id": "_design/test",
"views": {
    "all": {
        "map": "function(doc) {
            if (doc.nom) emit(doc._id, doc);
            }"
        },
    "asin_doc": {
        "map": "function(doc) {
            if (doc.category) emit(doc.asin, doc);
            }"
        },
    "asin": {
        "map": "function(doc) {
            if (doc.category) emit(doc.asin, null);
            }"
        }
    }
    }

The same document in a long string (Ruby):

"{\n\t\"_id\": \"_design/test\",\n\t\"views\": {\n\t\t\"all\": {\n\t\t\t\"map\": \"function(doc) {\n\t\t\t\tif (doc.nom) emit(doc._id, doc);\n\t\t\t}\"\n\t\t},\n\t\t\"asin_doc\": {\n\t\t\t\"map\": \"function(doc) {\n\t\t\t\tif (doc.category) emit(doc.asin, doc);\n\t\t\t}\"\n\t\t},\n\t\t\"asin\": {\n\t\t\t\"map\": \"function(doc) {\n\t\t\t\tif (doc.category) emit(doc.asin, null);\n\t\t\t}\"\n\t\t}\n\t}\n}\n"

JSLint tells me that there is a problem at line 5 character 20.

Problem at line 5 character 20: Unclosed string.
"map": "function(doc) {
Problem at line 5 character 20: Stopping. (25% scanned).
JSON: bad.

I can’t see where the string is not properly closed. Any idea ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:31:48+00:00Added an answer on May 25, 2026 at 8:31 pm

    Newline and tab are not allowed in a string. See the JSON RFC, specifically:

    unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
    

    EDIT: What json.org is talking about, I think, is this:

    Insignificant whitespace is allowed before or after any of the six structural characters.

    The “structural characters” are: [ ] { } : ,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the following code to create countdowns in Javascript. n is the number
I use following code-behind for javascript pop up for conforming, it works well but
I am trying to use following code to read a Google text document. But
I use the following code to compile a cpp file to object file. g++
I use the following code try to create an array of string vectors, I
I Use following code for single file drag and drop. private void FormRegion2_DragEnter_1(object sender,
I use following code to resize the image after i upload it. function re-sizes
I use following code to populate a Combo Box. It displays: System.Data.DataRowView instead of
I use following class to encrypt/decrypt my texts. http://code.google.com/p/iphonebits/source/browse/trunk/src/Encryption/NSData-AES.m?r=2 This works perfectly. But when
I use following code: protected object GetProperty(object target, string fieldName) { Type type =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.