Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

I am a beginner to groovy Technology how to read JSON file and how to validate JSON data in groovy.

2 answers

HI Irayya, 

Here is something I use to parse JSON in JIRA using scriptrunner. 

import groovy.json.JsonSlurper

String jsonFile = """{
 "Contact": {
 "me@me.com": ["Certif1","Certif2"],
 "me@me2.com": ["Certif3","Certif4"],
 "me@me3.com": ["Certif1","Certif4"]
 }
}"""

def mySlurper = new JsonSlurper()
def parsed = mySlurper.parseText(jsonFile)
return parsed.Contact."me@me.com"

if you parse a file instead of a String, you can use : 

File myFile = new File("Path")
mySlurper.parse(myFile)

Hope it help

0 votes

Atlassian applications do use JSON, and we do modify them with Groovy sometimes, but this is not really the best place to ask about this as a general subject.  You probably want a more Groovy based forum.

I've read json with groovy, but my code is rubbish and I'm sure it could have been written better.  A lot of people here won't have worked with either, it's sort of the wrong audience for your question.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you