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?
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
add a comment |
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
stackoverflow.com/help/mcve
– Marcin Orlowski
Mar 7 at 22:12
add a comment |
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
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
java android json
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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");
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
|
show 6 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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");
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
|
show 6 more comments
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");
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
|
show 6 more comments
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");
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");
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
|
show 6 more comments
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
|
show 6 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
stackoverflow.com/help/mcve
– Marcin Orlowski
Mar 7 at 22:12