Hello All
Im fairly new to this so bare with me if im asking stupid questions :)
I created a script in java that queries Jira server issue, and returns.. wall of text.
I cannot figure out how to receive formated json response like the ones im seeing all over internet.
This is how respond looks like, i had to obfuscate some of the text for obvoious resons:
{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"149225","self":"https://jnjsdasdortal.asdas.jasdasa.net/rest/api/2/issue/149225","key":"SDsasdasCSERVEasda31asd06":null,"customfield_10500":"2020-03-19","customfield_12404":null,"customfield_10501":null,"customfield_12403":null,"customfield_10502":null,"customfield_12406":null,"customfield_10503":null,"customfield_12405":"2020-03-09","customfield_10504":null,"customfield_12408":null,"customfield_12407":null,"lastViewed":"2020-03-11T12:09:58.574+0100","customfield_12000":null,"customfield_12002":null,"customfield_12001":null,"priority":{"self":"https://jnjirasdsatal.asddas.jsadasta.net/rest/api/2/priority/3","iconUrl":"https://jnjasdsasal.asdas.jasdasa.net/images/icons/priorities/medium.svg","name":"Medium","id":"3"},"customfield_12004":null,"customfield_12400":null,"customfield_12003":null,"customfield_12402":"2020-03-09","labels":[],"customfield_12401":"2020-03-06","customfield_11700":null,"customfield_11702":null,"customfield_11701":null
My java code:
public class Main {
public static void main(String[] args)throws Exception {
HttpResponse<JsonNode> response = Unirest.get("https://asdasjiraportal.asdasd.asdasds.net/rest/api/2/issue/SERVER-156")
.basicAuth("login", "password")
.header("Accept", "application/json")
.header("Content-Type","application/json")
.asJson();
System.out.println(response.getBody());
Can someone guide me where how i can declare formatting or point me to a good resource that is noob friendly?
json is a data interchange format with no display formatting. It's up to the rendering client to decide how it chooses to format.
When you view it in the browser, your browser is detecting it as json and formatting it for you in a way that's more digestible by humans.
In your example code, you'll want to run the response through a json parser to deserialize it. Then pass that through to a json formatting library to pretty print it to the console.
Thank you Randy, this is kind of what i expected : )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.