How to search a specific part of a JSON object and add to an already existing objectSafely turning a JSON string into an objectHow do I format a Microsoft JSON date?How can I pretty-print JSON in a shell script?How do I generate random integers within a specific range in Java?How do I test for an empty JavaScript object?Fling gesture detection on grid layoutHow to parse JSON in JavaConvert JS object to JSON stringHow can I pretty-print JSON using JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?

Does Doodling or Improvising on the Piano Have Any Benefits?

Personal or impersonal in a technical resume

How to make a list of partial sums using forEach

Make a Bowl of Alphabet Soup

What is this high flying aircraft over Pennsylvania?

Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?

PTIJ: Which Dr. Seuss books should one obtain?

Overlapping circles covering polygon

Check if object is null and return null

Do I have to take mana from my deck or hand when tapping a dual land?

How to reduce predictors the right way for a logistic regression model

The Digit Triangles

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

"Oh no!" in Latin

Proving an identity involving cross products and coplanar vectors

ContourPlot — How do I color by contour curvature?

Do you waste sorcery points if you try to apply metamagic to a spell from a scroll but fail to cast it?

Air travel with refrigerated insulin

Showing mass murder in a kid's book

Has the laser at Magurele, Romania reached a tenth of the Sun's power?

Ways of geometrical multiplication

El Dorado Word Puzzle II: Videogame Edition

Mimic lecturing on blackboard, facing audience

Alignment of six matrices



How to search a specific part of a JSON object and add to an already existing object


Safely turning a JSON string into an objectHow do I format a Microsoft JSON date?How can I pretty-print JSON in a shell script?How do I generate random integers within a specific range in Java?How do I test for an empty JavaScript object?Fling gesture detection on grid layoutHow to parse JSON in JavaConvert JS object to JSON stringHow can I pretty-print JSON using JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?













0















I'm new to using JSONs and I'm having a bit of difficulty. I am using the Kitsu API and parsing the JSON I get when I login. When I parse my json the image below pops up, but inside the 1 object array I want to get the large url in the avatar object inside of the attributes object and I don't know how.The beginning of the JSON, The middle of the JSON, The end. Lastly, I want to know how to edit the slug part of the JSON, if you don't know that's cool the main thing is getting the avatar url.



Picture of my error










share|improve this question
























  • stackoverflow.com/help/mcve

    – Marcin Orlowski
    Mar 7 at 22:12















0















I'm new to using JSONs and I'm having a bit of difficulty. I am using the Kitsu API and parsing the JSON I get when I login. When I parse my json the image below pops up, but inside the 1 object array I want to get the large url in the avatar object inside of the attributes object and I don't know how.The beginning of the JSON, The middle of the JSON, The end. Lastly, I want to know how to edit the slug part of the JSON, if you don't know that's cool the main thing is getting the avatar url.



Picture of my error










share|improve this question
























  • stackoverflow.com/help/mcve

    – Marcin Orlowski
    Mar 7 at 22:12













0












0








0








I'm new to using JSONs and I'm having a bit of difficulty. I am using the Kitsu API and parsing the JSON I get when I login. When I parse my json the image below pops up, but inside the 1 object array I want to get the large url in the avatar object inside of the attributes object and I don't know how.The beginning of the JSON, The middle of the JSON, The end. Lastly, I want to know how to edit the slug part of the JSON, if you don't know that's cool the main thing is getting the avatar url.



Picture of my error










share|improve this question
















I'm new to using JSONs and I'm having a bit of difficulty. I am using the Kitsu API and parsing the JSON I get when I login. When I parse my json the image below pops up, but inside the 1 object array I want to get the large url in the avatar object inside of the attributes object and I don't know how.The beginning of the JSON, The middle of the JSON, The end. Lastly, I want to know how to edit the slug part of the JSON, if you don't know that's cool the main thing is getting the avatar url.



Picture of my error







java android json






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 22:28







jmorg85

















asked Mar 7 at 22:10









jmorg85jmorg85

15




15












  • stackoverflow.com/help/mcve

    – Marcin Orlowski
    Mar 7 at 22:12

















  • stackoverflow.com/help/mcve

    – Marcin Orlowski
    Mar 7 at 22:12
















stackoverflow.com/help/mcve

– Marcin Orlowski
Mar 7 at 22:12





stackoverflow.com/help/mcve

– Marcin Orlowski
Mar 7 at 22:12












1 Answer
1






active

oldest

votes


















0














Please, try this...



JSONObject myObject = new JSONObject(jsonStr);
JSONArray myArray = myObject.getJSONArray("data");
JSONObject obj = myArray.getJSONObject(0);
String id = obj.getString("id");
String type = obj.getString("type");

//change the lines bellow
JSONObject attributes = obj.getJSONObject("attributes");
JSONObject avatar = attributes.getJSONObject("avatar");
String large = avatar.getString("large");





share|improve this answer

























  • Okay, I tried that and it's just not taking data, I'm also semi new to stack overflow so it'll be a bit before I add a picture of what I'm getting.

    – jmorg85
    Mar 7 at 22:27











  • Please, share your code where you are trying to read.

    – Bruno Carneiro
    Mar 7 at 22:39











  • JSONObject myObject = new JSONObject(jsonStr); JSONArray myArray = myObject.getJSONArray("data"); JSONObject obj = myArray.getJSONObject(0); String id = obj.getString("id"); String type = obj.getString("type"); JSONObject attributes = new JSONObject("attributes"); String avatar = jsonStr.data[0].attributes.avatar.large;

    – jmorg85
    Mar 7 at 22:44












  • I'm sorry, but due to stack overflow's character limit I can't put in the whole method.

    – jmorg85
    Mar 7 at 22:46











  • But yeah only data is red, while everything else if fine.

    – jmorg85
    Mar 7 at 22:47










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053622%2fhow-to-search-a-specific-part-of-a-json-object-and-add-to-an-already-existing-ob%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Please, try this...



JSONObject myObject = new JSONObject(jsonStr);
JSONArray myArray = myObject.getJSONArray("data");
JSONObject obj = myArray.getJSONObject(0);
String id = obj.getString("id");
String type = obj.getString("type");

//change the lines bellow
JSONObject attributes = obj.getJSONObject("attributes");
JSONObject avatar = attributes.getJSONObject("avatar");
String large = avatar.getString("large");





share|improve this answer

























  • Okay, I tried that and it's just not taking data, I'm also semi new to stack overflow so it'll be a bit before I add a picture of what I'm getting.

    – jmorg85
    Mar 7 at 22:27











  • Please, share your code where you are trying to read.

    – Bruno Carneiro
    Mar 7 at 22:39











  • JSONObject myObject = new JSONObject(jsonStr); JSONArray myArray = myObject.getJSONArray("data"); JSONObject obj = myArray.getJSONObject(0); String id = obj.getString("id"); String type = obj.getString("type"); JSONObject attributes = new JSONObject("attributes"); String avatar = jsonStr.data[0].attributes.avatar.large;

    – jmorg85
    Mar 7 at 22:44












  • I'm sorry, but due to stack overflow's character limit I can't put in the whole method.

    – jmorg85
    Mar 7 at 22:46











  • But yeah only data is red, while everything else if fine.

    – jmorg85
    Mar 7 at 22:47















0














Please, try this...



JSONObject myObject = new JSONObject(jsonStr);
JSONArray myArray = myObject.getJSONArray("data");
JSONObject obj = myArray.getJSONObject(0);
String id = obj.getString("id");
String type = obj.getString("type");

//change the lines bellow
JSONObject attributes = obj.getJSONObject("attributes");
JSONObject avatar = attributes.getJSONObject("avatar");
String large = avatar.getString("large");





share|improve this answer

























  • Okay, I tried that and it's just not taking data, I'm also semi new to stack overflow so it'll be a bit before I add a picture of what I'm getting.

    – jmorg85
    Mar 7 at 22:27











  • Please, share your code where you are trying to read.

    – Bruno Carneiro
    Mar 7 at 22:39











  • JSONObject myObject = new JSONObject(jsonStr); JSONArray myArray = myObject.getJSONArray("data"); JSONObject obj = myArray.getJSONObject(0); String id = obj.getString("id"); String type = obj.getString("type"); JSONObject attributes = new JSONObject("attributes"); String avatar = jsonStr.data[0].attributes.avatar.large;

    – jmorg85
    Mar 7 at 22:44












  • I'm sorry, but due to stack overflow's character limit I can't put in the whole method.

    – jmorg85
    Mar 7 at 22:46











  • But yeah only data is red, while everything else if fine.

    – jmorg85
    Mar 7 at 22:47













0












0








0







Please, try this...



JSONObject myObject = new JSONObject(jsonStr);
JSONArray myArray = myObject.getJSONArray("data");
JSONObject obj = myArray.getJSONObject(0);
String id = obj.getString("id");
String type = obj.getString("type");

//change the lines bellow
JSONObject attributes = obj.getJSONObject("attributes");
JSONObject avatar = attributes.getJSONObject("avatar");
String large = avatar.getString("large");





share|improve this answer















Please, try this...



JSONObject myObject = new JSONObject(jsonStr);
JSONArray myArray = myObject.getJSONArray("data");
JSONObject obj = myArray.getJSONObject(0);
String id = obj.getString("id");
String type = obj.getString("type");

//change the lines bellow
JSONObject attributes = obj.getJSONObject("attributes");
JSONObject avatar = attributes.getJSONObject("avatar");
String large = avatar.getString("large");






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 7 at 23:16

























answered Mar 7 at 22:21









Bruno CarneiroBruno Carneiro

1449




1449












  • Okay, I tried that and it's just not taking data, I'm also semi new to stack overflow so it'll be a bit before I add a picture of what I'm getting.

    – jmorg85
    Mar 7 at 22:27











  • Please, share your code where you are trying to read.

    – Bruno Carneiro
    Mar 7 at 22:39











  • JSONObject myObject = new JSONObject(jsonStr); JSONArray myArray = myObject.getJSONArray("data"); JSONObject obj = myArray.getJSONObject(0); String id = obj.getString("id"); String type = obj.getString("type"); JSONObject attributes = new JSONObject("attributes"); String avatar = jsonStr.data[0].attributes.avatar.large;

    – jmorg85
    Mar 7 at 22:44












  • I'm sorry, but due to stack overflow's character limit I can't put in the whole method.

    – jmorg85
    Mar 7 at 22:46











  • But yeah only data is red, while everything else if fine.

    – jmorg85
    Mar 7 at 22:47

















  • Okay, I tried that and it's just not taking data, I'm also semi new to stack overflow so it'll be a bit before I add a picture of what I'm getting.

    – jmorg85
    Mar 7 at 22:27











  • Please, share your code where you are trying to read.

    – Bruno Carneiro
    Mar 7 at 22:39











  • JSONObject myObject = new JSONObject(jsonStr); JSONArray myArray = myObject.getJSONArray("data"); JSONObject obj = myArray.getJSONObject(0); String id = obj.getString("id"); String type = obj.getString("type"); JSONObject attributes = new JSONObject("attributes"); String avatar = jsonStr.data[0].attributes.avatar.large;

    – jmorg85
    Mar 7 at 22:44












  • I'm sorry, but due to stack overflow's character limit I can't put in the whole method.

    – jmorg85
    Mar 7 at 22:46











  • But yeah only data is red, while everything else if fine.

    – jmorg85
    Mar 7 at 22:47
















Okay, I tried that and it's just not taking data, I'm also semi new to stack overflow so it'll be a bit before I add a picture of what I'm getting.

– jmorg85
Mar 7 at 22:27





Okay, I tried that and it's just not taking data, I'm also semi new to stack overflow so it'll be a bit before I add a picture of what I'm getting.

– jmorg85
Mar 7 at 22:27













Please, share your code where you are trying to read.

– Bruno Carneiro
Mar 7 at 22:39





Please, share your code where you are trying to read.

– Bruno Carneiro
Mar 7 at 22:39













JSONObject myObject = new JSONObject(jsonStr); JSONArray myArray = myObject.getJSONArray("data"); JSONObject obj = myArray.getJSONObject(0); String id = obj.getString("id"); String type = obj.getString("type"); JSONObject attributes = new JSONObject("attributes"); String avatar = jsonStr.data[0].attributes.avatar.large;

– jmorg85
Mar 7 at 22:44






JSONObject myObject = new JSONObject(jsonStr); JSONArray myArray = myObject.getJSONArray("data"); JSONObject obj = myArray.getJSONObject(0); String id = obj.getString("id"); String type = obj.getString("type"); JSONObject attributes = new JSONObject("attributes"); String avatar = jsonStr.data[0].attributes.avatar.large;

– jmorg85
Mar 7 at 22:44














I'm sorry, but due to stack overflow's character limit I can't put in the whole method.

– jmorg85
Mar 7 at 22:46





I'm sorry, but due to stack overflow's character limit I can't put in the whole method.

– jmorg85
Mar 7 at 22:46













But yeah only data is red, while everything else if fine.

– jmorg85
Mar 7 at 22:47





But yeah only data is red, while everything else if fine.

– jmorg85
Mar 7 at 22:47



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053622%2fhow-to-search-a-specific-part-of-a-json-object-and-add-to-an-already-existing-ob%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived