How to extract a second tier property of json object from server response










0















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?










share|improve this question






















  • 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















0















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?










share|improve this question






















  • 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













0












0








0








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 15:32









RaventusRaventus

215




215












  • 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

















  • 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
















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












2 Answers
2






active

oldest

votes


















0














Just try like this item["Data"].Search or item["Data"]["Search"] . So here basically you're targeting Search property of Data object






share|improve this answer























  • Unfortunately, neither of the two methods worked. I'm still get an undefined value;(

    – Raventus
    Nov 13 '18 at 15:48



















0














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);

);





share|improve this answer























  • 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










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%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









0














Just try like this item["Data"].Search or item["Data"]["Search"] . So here basically you're targeting Search property of Data object






share|improve this answer























  • Unfortunately, neither of the two methods worked. I'm still get an undefined value;(

    – Raventus
    Nov 13 '18 at 15:48
















0














Just try like this item["Data"].Search or item["Data"]["Search"] . So here basically you're targeting Search property of Data object






share|improve this answer























  • Unfortunately, neither of the two methods worked. I'm still get an undefined value;(

    – Raventus
    Nov 13 '18 at 15:48














0












0








0







Just try like this item["Data"].Search or item["Data"]["Search"] . So here basically you're targeting Search property of Data object






share|improve this answer













Just try like this item["Data"].Search or item["Data"]["Search"] . So here basically you're targeting Search property of Data object







share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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














0














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);

);





share|improve this answer























  • 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















0














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);

);





share|improve this answer























  • 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













0












0








0







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);

);





share|improve this answer













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);

);






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 0:12









RaventusRaventus

215




215












  • 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
















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

















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%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





















































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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3