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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:47:48+00:00 2026-06-06T09:47:48+00:00

So either I go back and tell someone that they should fix their JSON,

  • 0

So either I go back and tell someone that they should fix their JSON, or I need to find out what I am doing wrong. Here is the JSON, notice that parameter occurs three times:

String j= '''{
    "jobname" : "test",
    "parameters" : {
    "parameter": {"name":"maxErrors", "value":"0"},
    "parameter": {"name":"case", "value":"lower"},
    "parameter": {"name":"mapTable", "value":"1"}
    }
} '''

And I am trying to get each name & value. My code

def doc = new JsonSlurper().parseText(j)
def doc1 = doc.entrySet() as List
def doc2 = doc.parameters.entrySet() as List
println "doc1.size===>"+doc1.size()
println "doc1===>"+doc1
println "doc2.size===>"+doc2.size()
println "doc2===>"+doc2

And my results:

doc1.size===>2
doc1===>[jobname=test, parameters={parameter={name=mapTable, value=1}}]
doc2.size===>1
doc2===>[parameter={name=mapTable, value=1}]

How come I only get one parameter? Where are the other two? It looks like JSON only keeps one parameter and discards the other ones.

  • 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-06T09:47:54+00:00Added an answer on June 6, 2026 at 9:47 am

    The JSON is not in the correct format. There should not be duplicate key in the same hierarchy or they will override each other.

    It should have been an array of paramters.

    Like this,

    String j= '''{
     "jobname" : "test",
     "parameters" : [
     {"name":"maxErrors", "value":"0"},
     {"name":"case", "value":"lower"},
     {"name":"mapTable", "value":"1"}
     ]
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm hoping someone can either tell me what I'm doing wrong correct my flawed
I'm hoping someone can find this problem. I had an app that was fully
I either get a you need a ; here or a best overloaded match
I need to either bring front browser window if it is already running or
I need to capture either \d+\.\d+ or \d+ but nothing else. For instance ,
I have a java web app that makes back-end use of a third-party web
I am trying to find out the maximum value for an integer (signed or
A site that I'm working on has a ASP.NET webforms page that posts back
I'm making a back-end function for another area of a program that will add
I have a contact form that connects to my site's back-end, the form submits

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.