How to get components using python JIRA library

Sandeep June 16, 2022

Hi All,

We are using Python JIRA library to retrieve details about JIRA Project. We are looking to get component information and for that we are using the "project_components" function mentioned in this documentation https://jira.readthedocs.io/examples.html#projects

But the output returned by this function is in a list format and we are unable to convert this list out to JSON format. Can anyone let me know how to parse the below output we are getting from the project_componets function call. Or if there is a better way to components let me know please

[
<JIRA Component: name=u'component1', id=u'componentid1'>,
<JIRA Component: name=u'component2', id=u'componentid2'>
]

1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 21, 2022

Hi,

Welcome to the community

First create a new list with te name of all you components

listeName = [component.name for component in componentList]

then convert the list to json

import json

jsonList = json.dumps(listeName)

 

https://pythonexamples.org/python-list-to-json/

Suggest an answer

Log in or Sign up to answer