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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page