How to extract a second tier property of json object from server response
I'm new in angular and I'm stack in simple task.
Using http.get() method I get from the server this json object like this:
Data : Search:[, , ...], ...
...
After doing code like this:
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]);
I'm success extract the Data property of this object, but my goal is to extract the Search property of Data property. But after doing this code
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]).map(temp=>temp["Search"]);
I'm extract an undefined object. I guess that it is simple task and I miss some simple solution. My question is how to extract the Serch property of Data property of JSON object from the server?
angular
|
show 1 more comment
I'm new in angular and I'm stack in simple task.
Using http.get() method I get from the server this json object like this:
Data : Search:[, , ...], ...
...
After doing code like this:
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]);
I'm success extract the Data property of this object, but my goal is to extract the Search property of Data property. But after doing this code
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]).map(temp=>temp["Search"]);
I'm extract an undefined object. I guess that it is simple task and I miss some simple solution. My question is how to extract the Serch property of Data property of JSON object from the server?
angular
Do you get Search object when youconsole.log(item["Data"])
?
– User3250
Nov 13 '18 at 16:07
after this code var dataObject = this.httpRequest.Get() .map(item=> item["Data"]) .subscribe(val => console.log(val)); In my console I will get: {"Search":["Title":"The Godfather","Year":"1972","imdbID":"tt0068646", ..., ...]
– Raventus
Nov 13 '18 at 16:19
Ok, hereval.Search
should give you what you need.
– User3250
Nov 13 '18 at 16:24
It is magic, but I'm still get the undefined object, I can't understand it. This approach should work. Maybe this is beacause Search is an array of objects?
– Raventus
Nov 13 '18 at 16:30
try this insteadthis.httpRequest.Get().map(item=> item.Data.Search)
– User3250
Nov 13 '18 at 16:35
|
show 1 more comment
I'm new in angular and I'm stack in simple task.
Using http.get() method I get from the server this json object like this:
Data : Search:[, , ...], ...
...
After doing code like this:
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]);
I'm success extract the Data property of this object, but my goal is to extract the Search property of Data property. But after doing this code
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]).map(temp=>temp["Search"]);
I'm extract an undefined object. I guess that it is simple task and I miss some simple solution. My question is how to extract the Serch property of Data property of JSON object from the server?
angular
I'm new in angular and I'm stack in simple task.
Using http.get() method I get from the server this json object like this:
Data : Search:[, , ...], ...
...
After doing code like this:
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]);
I'm success extract the Data property of this object, but my goal is to extract the Search property of Data property. But after doing this code
var dataObject = this.httpRequest.Get()
.map(item=> item["Data"]).map(temp=>temp["Search"]);
I'm extract an undefined object. I guess that it is simple task and I miss some simple solution. My question is how to extract the Serch property of Data property of JSON object from the server?
angular
angular
asked Nov 13 '18 at 15:32
RaventusRaventus
215
215
Do you get Search object when youconsole.log(item["Data"])
?
– User3250
Nov 13 '18 at 16:07
after this code var dataObject = this.httpRequest.Get() .map(item=> item["Data"]) .subscribe(val => console.log(val)); In my console I will get: {"Search":["Title":"The Godfather","Year":"1972","imdbID":"tt0068646", ..., ...]
– Raventus
Nov 13 '18 at 16:19
Ok, hereval.Search
should give you what you need.
– User3250
Nov 13 '18 at 16:24
It is magic, but I'm still get the undefined object, I can't understand it. This approach should work. Maybe this is beacause Search is an array of objects?
– Raventus
Nov 13 '18 at 16:30
try this insteadthis.httpRequest.Get().map(item=> item.Data.Search)
– User3250
Nov 13 '18 at 16:35
|
show 1 more comment
Do you get Search object when youconsole.log(item["Data"])
?
– User3250
Nov 13 '18 at 16:07
after this code var dataObject = this.httpRequest.Get() .map(item=> item["Data"]) .subscribe(val => console.log(val)); In my console I will get: {"Search":["Title":"The Godfather","Year":"1972","imdbID":"tt0068646", ..., ...]
– Raventus
Nov 13 '18 at 16:19
Ok, hereval.Search
should give you what you need.
– User3250
Nov 13 '18 at 16:24
It is magic, but I'm still get the undefined object, I can't understand it. This approach should work. Maybe this is beacause Search is an array of objects?
– Raventus
Nov 13 '18 at 16:30
try this insteadthis.httpRequest.Get().map(item=> item.Data.Search)
– User3250
Nov 13 '18 at 16:35
Do you get Search object when you
console.log(item["Data"])
?– User3250
Nov 13 '18 at 16:07
Do you get Search object when you
console.log(item["Data"])
?– User3250
Nov 13 '18 at 16:07
after this code var dataObject = this.httpRequest.Get() .map(item=> item["Data"]) .subscribe(val => console.log(val)); In my console I will get: {"Search":["Title":"The Godfather","Year":"1972","imdbID":"tt0068646", ..., ...]
– Raventus
Nov 13 '18 at 16:19
after this code var dataObject = this.httpRequest.Get() .map(item=> item["Data"]) .subscribe(val => console.log(val)); In my console I will get: {"Search":["Title":"The Godfather","Year":"1972","imdbID":"tt0068646", ..., ...]
– Raventus
Nov 13 '18 at 16:19
Ok, here
val.Search
should give you what you need.– User3250
Nov 13 '18 at 16:24
Ok, here
val.Search
should give you what you need.– User3250
Nov 13 '18 at 16:24
It is magic, but I'm still get the undefined object, I can't understand it. This approach should work. Maybe this is beacause Search is an array of objects?
– Raventus
Nov 13 '18 at 16:30
It is magic, but I'm still get the undefined object, I can't understand it. This approach should work. Maybe this is beacause Search is an array of objects?
– Raventus
Nov 13 '18 at 16:30
try this instead
this.httpRequest.Get().map(item=> item.Data.Search)
– User3250
Nov 13 '18 at 16:35
try this instead
this.httpRequest.Get().map(item=> item.Data.Search)
– User3250
Nov 13 '18 at 16:35
|
show 1 more comment
2 Answers
2
active
oldest
votes
Just try like this item["Data"].Search
or item["Data"]["Search"]
. So here basically you're targeting Search property of Data object
Unfortunately, neither of the two methods worked. I'm still get an undefined value;(
– Raventus
Nov 13 '18 at 15:48
add a comment |
The problem was that Data property is string, not a JSON object, that is why I can't extract the Search array. The solution is
var dataObject = this.httpRequest.Get()
.map(item=> JSON.parse(item.Data))
.subscribe(val =>
console.log(val.Search);
);
Which version of angular you using? If version 4.3+ you must useHttpClient
which would auto parse JSON for you and you don't need to parse it manually.
– User3250
Nov 14 '18 at 3:05
add a comment |
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%2f53284376%2fhow-to-extract-a-second-tier-property-of-json-object-from-server-response%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just try like this item["Data"].Search
or item["Data"]["Search"]
. So here basically you're targeting Search property of Data object
Unfortunately, neither of the two methods worked. I'm still get an undefined value;(
– Raventus
Nov 13 '18 at 15:48
add a comment |
Just try like this item["Data"].Search
or item["Data"]["Search"]
. So here basically you're targeting Search property of Data object
Unfortunately, neither of the two methods worked. I'm still get an undefined value;(
– Raventus
Nov 13 '18 at 15:48
add a comment |
Just try like this item["Data"].Search
or item["Data"]["Search"]
. So here basically you're targeting Search property of Data object
Just try like this item["Data"].Search
or item["Data"]["Search"]
. So here basically you're targeting Search property of Data object
answered Nov 13 '18 at 15:34
Slobodan GajićSlobodan Gajić
104110
104110
Unfortunately, neither of the two methods worked. I'm still get an undefined value;(
– Raventus
Nov 13 '18 at 15:48
add a comment |
Unfortunately, neither of the two methods worked. I'm still get an undefined value;(
– Raventus
Nov 13 '18 at 15:48
Unfortunately, neither of the two methods worked. I'm still get an undefined value;(
– Raventus
Nov 13 '18 at 15:48
Unfortunately, neither of the two methods worked. I'm still get an undefined value;(
– Raventus
Nov 13 '18 at 15:48
add a comment |
The problem was that Data property is string, not a JSON object, that is why I can't extract the Search array. The solution is
var dataObject = this.httpRequest.Get()
.map(item=> JSON.parse(item.Data))
.subscribe(val =>
console.log(val.Search);
);
Which version of angular you using? If version 4.3+ you must useHttpClient
which would auto parse JSON for you and you don't need to parse it manually.
– User3250
Nov 14 '18 at 3:05
add a comment |
The problem was that Data property is string, not a JSON object, that is why I can't extract the Search array. The solution is
var dataObject = this.httpRequest.Get()
.map(item=> JSON.parse(item.Data))
.subscribe(val =>
console.log(val.Search);
);
Which version of angular you using? If version 4.3+ you must useHttpClient
which would auto parse JSON for you and you don't need to parse it manually.
– User3250
Nov 14 '18 at 3:05
add a comment |
The problem was that Data property is string, not a JSON object, that is why I can't extract the Search array. The solution is
var dataObject = this.httpRequest.Get()
.map(item=> JSON.parse(item.Data))
.subscribe(val =>
console.log(val.Search);
);
The problem was that Data property is string, not a JSON object, that is why I can't extract the Search array. The solution is
var dataObject = this.httpRequest.Get()
.map(item=> JSON.parse(item.Data))
.subscribe(val =>
console.log(val.Search);
);
answered Nov 14 '18 at 0:12
RaventusRaventus
215
215
Which version of angular you using? If version 4.3+ you must useHttpClient
which would auto parse JSON for you and you don't need to parse it manually.
– User3250
Nov 14 '18 at 3:05
add a comment |
Which version of angular you using? If version 4.3+ you must useHttpClient
which would auto parse JSON for you and you don't need to parse it manually.
– User3250
Nov 14 '18 at 3:05
Which version of angular you using? If version 4.3+ you must use
HttpClient
which would auto parse JSON for you and you don't need to parse it manually.– User3250
Nov 14 '18 at 3:05
Which version of angular you using? If version 4.3+ you must use
HttpClient
which would auto parse JSON for you and you don't need to parse it manually.– User3250
Nov 14 '18 at 3:05
add a comment |
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%2f53284376%2fhow-to-extract-a-second-tier-property-of-json-object-from-server-response%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
Do you get Search object when you
console.log(item["Data"])
?– User3250
Nov 13 '18 at 16:07
after this code var dataObject = this.httpRequest.Get() .map(item=> item["Data"]) .subscribe(val => console.log(val)); In my console I will get: {"Search":["Title":"The Godfather","Year":"1972","imdbID":"tt0068646", ..., ...]
– Raventus
Nov 13 '18 at 16:19
Ok, here
val.Search
should give you what you need.– User3250
Nov 13 '18 at 16:24
It is magic, but I'm still get the undefined object, I can't understand it. This approach should work. Maybe this is beacause Search is an array of objects?
– Raventus
Nov 13 '18 at 16:30
try this instead
this.httpRequest.Get().map(item=> item.Data.Search)
– User3250
Nov 13 '18 at 16:35