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

  • Home
  • SEARCH
  • 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 6372395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:13:57+00:00 2026-05-25T01:13:57+00:00

The JSON in question is being read in from a RESTful service, and I

  • 0

The JSON in question is being read in from a RESTful service, and I would like to print it out (to console, although in .gsp would be fine also) for debugging purposes. Groovy 1.3.7 (current as of August 2011) uses Groovy 1.7.8 (which does not have the JsonOutput introduced in 1.8)

Note I am currently reading it in like this, which I am not convinced is the ‘grooviest or grail-est’ way to do it – perhaps I could take advantage of the converters and pretty printing if done differently? Code sample would be appreciated.

   def serviceURL = new URL(theURL)
   def json = new JSONObject(serviceURL.text)
   println json
  • 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-25T01:13:57+00:00Added an answer on May 25, 2026 at 1:13 am

    You can pretty print JSON with the toString(int indentFactor) method. Example:

    def json = new JSONObject()
    json.put('foo', 'bar')
    json.put('blat', 'greep')
    println json
    ===>{"foo":"bar","blat","greep"}
    println json.toString(4)
    ===>{
        "foo": "bar",
        "blat": "greep"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a quick question regarding json responses from the web services, I
Question: I'm using eval to parse a JSON return value from one of my
After my last question was solved the JSON I'm receiving from the server changed
I've a little question about decoding special characters from a JSon result (in my
From a previous question on Stackoverflow Iterating through/Parsing JSON Object via JavaScript .... My
This might seem like an unordinary json question but I can assure you I
It looks like good JSON objects typically have a name-value pair, with value being
I have AJAX requests from which I get a JSON-format response, which is being
I'm trying to acquire a JSON which is being sent from an https secure
I've built a JSON API in Django. I'd like to send real-time updates from

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.