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 8538609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:09:30+00:00 2026-06-11T11:09:30+00:00

I have grails app that makes a REST call. If an error occurs, a

  • 0

I have grails app that makes a REST call. If an error occurs, a JSON array containing the error messages is returned. I need to combine these strings into a single string. However, when I do so double quotes are added to the front and end of the string. I have written a simple test controller to illustrate the problem:

import net.sf.json.*
class MyController {

    def test = {

        String msg = "'fred' is not a valid LDAP distinguished name."
        JSONArray messages = new JSONArray()
        messages.add(msg)
        def renderStr = messages.join('<br/>')

        render(renderStr)
    }
}

The output looks like this:

"'fred' is not a valid LDAP distinguished name."
  • 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-06-11T11:09:32+00:00Added an answer on June 11, 2026 at 11:09 am

    The problem is that the join function returns JSON-spec strings… which, according to their documentation here: http://grails.org/doc/1.0.3/api/org/codehaus/groovy/grails/web/json/JSONArray.html

     The texts produced by the toString methods strictly conform to JSON syntax rules. The constructors are more forgiving in the texts they will accept:
    
        An extra , (comma) may appear just before the closing bracket.
        The null value will be inserted when there is , (comma) elision.
        Strings may be quoted with ' (single quote).
        Strings do not need to be quoted at all if they do not begin with a quote or single quote, and if they do not contain leading or trailing spaces, and if they do not contain any of these characters: { } [ ] / \ : , = ; # and if they do not look like numbers and if they are not the reserved words true, false, or null.
        Values can be separated by ; (semicolon) as well as by , (comma).
        Numbers may have the 0- (octal) or 0x- (hex) prefix.
        Comments written in the slashshlash, slashstar, and hash conventions will be ignored.
    

    Note that the rule that “Strings do not need to be quoted at all if they do not begin with a quote or single quote” is what’s happening. Your string starts with a quote, so if it was output without quotes, a JSON parser would assume the string ended at the 2nd single-quote, and the text afterwards would be unparseable garbage.

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

Sidebar

Related Questions

I have a Groovy/Grails web app that reads e-mails from Gmail. It gets messages
I have a Grails app running on 1.3.7 with the json-rest-api plugin version 1.0.8
I have a Grails app that loads its data from xml files and delivers
I am writing a Grails/Groovy app and I have a JSON object with a
Im building a Grails app that will have multiple similar websites (each it's own
I have a grails app and I need to trigger an cpu-intensive process. I'm
I have a Grails 2.0.0 project that was created using grails create-app . In
I have a Grails 1.2 app secured with acegi that I'm monitoring with the
I have a grails app that uses functionality from a set of custom java
I have noticed that after my Grails app has been deployed for about 2

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.