How to render grand child and remove JSON object2019 Community Moderator ElectionSafely turning a JSON string into an objectHow do I format a Microsoft JSON date?How do I check if an array includes an object in JavaScript?How can I pretty-print JSON in a shell script?How do I test for an empty JavaScript object?Convert JS object to JSON stringHow to check if an object is an array?How can I pretty-print JSON using JavaScript?How do I remove a particular element from an array in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?
Are all players supposed to be able to see each others' character sheets?
Having the player face themselves after the mid-game
Help! My Character is too much for her story!
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
Is it appropriate to ask a former professor to order a book for me through an inter-library loan?
Can one live in the U.S. and not use a credit card?
Is there a logarithm base for which the logarithm becomes an identity function?
Writing text next to a table
Why do phishing e-mails use faked e-mail addresses instead of the real one?
Rationale to prefer local variables over instance variables?
When an outsider describes family relationships, which point of view are they using?
Do black holes violate the conservation of mass?
Either of .... (Plural/Singular)
PTIJ: Sport in the Torah
How should I solve this integral with changing parameters?
The (Easy) Road to Code
How do I raise a figure (placed with wrapfig) to be flush with the top of a paragraph?
What is the purpose of a disclaimer like "this is not legal advice"?
Use Mercury as quenching liquid for swords?
How to open new window on center of screen
Which country has more?
Strange opamp's output impedance in spice
-1 to the power of a irrational number
Difference between `nmap local-IP-address` and `nmap localhost`
How to render grand child and remove JSON object
2019 Community Moderator ElectionSafely turning a JSON string into an objectHow do I format a Microsoft JSON date?How do I check if an array includes an object in JavaScript?How can I pretty-print JSON in a shell script?How do I test for an empty JavaScript object?Convert JS object to JSON stringHow to check if an object is an array?How can I pretty-print JSON using JavaScript?How do I remove a particular element from an array in JavaScript?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?
I have a Json arry like
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1: validationMessage: …, id: -2147482622, partTypeId: null, partType: null, partCategoryId: 2, …
2: validationMessage: …, id: -2147482621, partTypeId: null, partType: null, partCategoryId: 5, …
from insde it looks like this
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1:
repairFacility: null
resourcePredictions: null
revision: null
specification: null
validationMessage:
errors: Array(1)
0:
attemptedValue: "147-6268-5715"
customState: null
errorCode: "PredicateValidator"
errorMessage: "This is warning "
[Solved]My first question how can I render my validation errorMessage: which is under each of my array element ->validationMessage>errors[0]->errorMessage
so far I can render other elements and here is my code. but for error message it shows x is not defined
<TableBody>
this.props.data ? this.props.data.map((item, i) => (
<TableRow key=i>
x = function myFunction(item)
if (item.validationMessage.erros[0].length > 0)
return item.validationMessage.erros[0].errorMessage
else
return ''
<TableCell align="right">x</TableCell> ////Want to render ERRORMESSAGE
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
)) : ''
</TableBody>
My second question is
how can I remove "validationMessage:" from my JSON? here is my try
removemsg()
const data = this.props
let out = null;
if (data)
out = data.delete("validationMessage");
arrays json reactjs
add a comment |
I have a Json arry like
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1: validationMessage: …, id: -2147482622, partTypeId: null, partType: null, partCategoryId: 2, …
2: validationMessage: …, id: -2147482621, partTypeId: null, partType: null, partCategoryId: 5, …
from insde it looks like this
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1:
repairFacility: null
resourcePredictions: null
revision: null
specification: null
validationMessage:
errors: Array(1)
0:
attemptedValue: "147-6268-5715"
customState: null
errorCode: "PredicateValidator"
errorMessage: "This is warning "
[Solved]My first question how can I render my validation errorMessage: which is under each of my array element ->validationMessage>errors[0]->errorMessage
so far I can render other elements and here is my code. but for error message it shows x is not defined
<TableBody>
this.props.data ? this.props.data.map((item, i) => (
<TableRow key=i>
x = function myFunction(item)
if (item.validationMessage.erros[0].length > 0)
return item.validationMessage.erros[0].errorMessage
else
return ''
<TableCell align="right">x</TableCell> ////Want to render ERRORMESSAGE
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
)) : ''
</TableBody>
My second question is
how can I remove "validationMessage:" from my JSON? here is my try
removemsg()
const data = this.props
let out = null;
if (data)
out = data.delete("validationMessage");
arrays json reactjs
add a comment |
I have a Json arry like
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1: validationMessage: …, id: -2147482622, partTypeId: null, partType: null, partCategoryId: 2, …
2: validationMessage: …, id: -2147482621, partTypeId: null, partType: null, partCategoryId: 5, …
from insde it looks like this
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1:
repairFacility: null
resourcePredictions: null
revision: null
specification: null
validationMessage:
errors: Array(1)
0:
attemptedValue: "147-6268-5715"
customState: null
errorCode: "PredicateValidator"
errorMessage: "This is warning "
[Solved]My first question how can I render my validation errorMessage: which is under each of my array element ->validationMessage>errors[0]->errorMessage
so far I can render other elements and here is my code. but for error message it shows x is not defined
<TableBody>
this.props.data ? this.props.data.map((item, i) => (
<TableRow key=i>
x = function myFunction(item)
if (item.validationMessage.erros[0].length > 0)
return item.validationMessage.erros[0].errorMessage
else
return ''
<TableCell align="right">x</TableCell> ////Want to render ERRORMESSAGE
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
)) : ''
</TableBody>
My second question is
how can I remove "validationMessage:" from my JSON? here is my try
removemsg()
const data = this.props
let out = null;
if (data)
out = data.delete("validationMessage");
arrays json reactjs
I have a Json arry like
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1: validationMessage: …, id: -2147482622, partTypeId: null, partType: null, partCategoryId: 2, …
2: validationMessage: …, id: -2147482621, partTypeId: null, partType: null, partCategoryId: 5, …
from insde it looks like this
Array(3)
0: validationMessage: …, id: -2147482623, partTypeId: null, partType: null, partCategoryId: 5, …
1:
repairFacility: null
resourcePredictions: null
revision: null
specification: null
validationMessage:
errors: Array(1)
0:
attemptedValue: "147-6268-5715"
customState: null
errorCode: "PredicateValidator"
errorMessage: "This is warning "
[Solved]My first question how can I render my validation errorMessage: which is under each of my array element ->validationMessage>errors[0]->errorMessage
so far I can render other elements and here is my code. but for error message it shows x is not defined
<TableBody>
this.props.data ? this.props.data.map((item, i) => (
<TableRow key=i>
x = function myFunction(item)
if (item.validationMessage.erros[0].length > 0)
return item.validationMessage.erros[0].errorMessage
else
return ''
<TableCell align="right">x</TableCell> ////Want to render ERRORMESSAGE
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
)) : ''
</TableBody>
My second question is
how can I remove "validationMessage:" from my JSON? here is my try
removemsg()
const data = this.props
let out = null;
if (data)
out = data.delete("validationMessage");
arrays json reactjs
arrays json reactjs
edited Mar 6 at 14:46
user2019
asked Mar 6 at 13:36
user2019user2019
3419
3419
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
For your first question you can simply put an if statement (using the ternary operator) inside the brackets where you currently have the x. I think this should suffice. I've also taken the liberty to return the stuff within your map function.
<TableBody>
(this.props.data)
? this.props.data.map((item, i) => (
return (
<TableRow key=i>
<TableCell align="right">
(item.validationMessage.errors[0].length > 0)
? item.validationMessage.errors[0].errorMessage
: ''
</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
);
))
: ''
Thank you @ApplePearPerson its working
– user2019
Mar 6 at 14:44
add a comment |
First question
To render your error only if the length of your array is different to 0, you could use conditional rendering.
A length of 0 will not return anything using the && operator, as it is falsy :
<TableBody>
this.props.data && this.props.data.map((item, i) => (
<TableRow key=i>
<TableCell align="right">item.validationMessage.erros[0].length && item.validationMessage.erros[0].errorMessage</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
))
</TableBody>
Second question
To extract only a given variable out of a JSON, you can use deconstruction and then use the deconstructing operator ... to get everything lefy of your object in a variable, here named newData :
removemsg()
const data = = this.props
const validationMessage, ...newData = data
console.log(newData)
However, you cannot directly modify your props.
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%2f55024416%2fhow-to-render-grand-child-and-remove-json-object%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
For your first question you can simply put an if statement (using the ternary operator) inside the brackets where you currently have the x. I think this should suffice. I've also taken the liberty to return the stuff within your map function.
<TableBody>
(this.props.data)
? this.props.data.map((item, i) => (
return (
<TableRow key=i>
<TableCell align="right">
(item.validationMessage.errors[0].length > 0)
? item.validationMessage.errors[0].errorMessage
: ''
</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
);
))
: ''
Thank you @ApplePearPerson its working
– user2019
Mar 6 at 14:44
add a comment |
For your first question you can simply put an if statement (using the ternary operator) inside the brackets where you currently have the x. I think this should suffice. I've also taken the liberty to return the stuff within your map function.
<TableBody>
(this.props.data)
? this.props.data.map((item, i) => (
return (
<TableRow key=i>
<TableCell align="right">
(item.validationMessage.errors[0].length > 0)
? item.validationMessage.errors[0].errorMessage
: ''
</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
);
))
: ''
Thank you @ApplePearPerson its working
– user2019
Mar 6 at 14:44
add a comment |
For your first question you can simply put an if statement (using the ternary operator) inside the brackets where you currently have the x. I think this should suffice. I've also taken the liberty to return the stuff within your map function.
<TableBody>
(this.props.data)
? this.props.data.map((item, i) => (
return (
<TableRow key=i>
<TableCell align="right">
(item.validationMessage.errors[0].length > 0)
? item.validationMessage.errors[0].errorMessage
: ''
</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
);
))
: ''
For your first question you can simply put an if statement (using the ternary operator) inside the brackets where you currently have the x. I think this should suffice. I've also taken the liberty to return the stuff within your map function.
<TableBody>
(this.props.data)
? this.props.data.map((item, i) => (
return (
<TableRow key=i>
<TableCell align="right">
(item.validationMessage.errors[0].length > 0)
? item.validationMessage.errors[0].errorMessage
: ''
</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
);
))
: ''
answered Mar 6 at 13:45
ApplePearPersonApplePearPerson
30610
30610
Thank you @ApplePearPerson its working
– user2019
Mar 6 at 14:44
add a comment |
Thank you @ApplePearPerson its working
– user2019
Mar 6 at 14:44
Thank you @ApplePearPerson its working
– user2019
Mar 6 at 14:44
Thank you @ApplePearPerson its working
– user2019
Mar 6 at 14:44
add a comment |
First question
To render your error only if the length of your array is different to 0, you could use conditional rendering.
A length of 0 will not return anything using the && operator, as it is falsy :
<TableBody>
this.props.data && this.props.data.map((item, i) => (
<TableRow key=i>
<TableCell align="right">item.validationMessage.erros[0].length && item.validationMessage.erros[0].errorMessage</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
))
</TableBody>
Second question
To extract only a given variable out of a JSON, you can use deconstruction and then use the deconstructing operator ... to get everything lefy of your object in a variable, here named newData :
removemsg()
const data = = this.props
const validationMessage, ...newData = data
console.log(newData)
However, you cannot directly modify your props.
add a comment |
First question
To render your error only if the length of your array is different to 0, you could use conditional rendering.
A length of 0 will not return anything using the && operator, as it is falsy :
<TableBody>
this.props.data && this.props.data.map((item, i) => (
<TableRow key=i>
<TableCell align="right">item.validationMessage.erros[0].length && item.validationMessage.erros[0].errorMessage</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
))
</TableBody>
Second question
To extract only a given variable out of a JSON, you can use deconstruction and then use the deconstructing operator ... to get everything lefy of your object in a variable, here named newData :
removemsg()
const data = = this.props
const validationMessage, ...newData = data
console.log(newData)
However, you cannot directly modify your props.
add a comment |
First question
To render your error only if the length of your array is different to 0, you could use conditional rendering.
A length of 0 will not return anything using the && operator, as it is falsy :
<TableBody>
this.props.data && this.props.data.map((item, i) => (
<TableRow key=i>
<TableCell align="right">item.validationMessage.erros[0].length && item.validationMessage.erros[0].errorMessage</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
))
</TableBody>
Second question
To extract only a given variable out of a JSON, you can use deconstruction and then use the deconstructing operator ... to get everything lefy of your object in a variable, here named newData :
removemsg()
const data = = this.props
const validationMessage, ...newData = data
console.log(newData)
However, you cannot directly modify your props.
First question
To render your error only if the length of your array is different to 0, you could use conditional rendering.
A length of 0 will not return anything using the && operator, as it is falsy :
<TableBody>
this.props.data && this.props.data.map((item, i) => (
<TableRow key=i>
<TableCell align="right">item.validationMessage.erros[0].length && item.validationMessage.erros[0].errorMessage</TableCell>
<TableCell align="right">item.partNumber</TableCell>
<TableCell align="right">item.description</TableCell>
<TableCell align="right">item.partCategoryId</TableCell>
<TableCell align="right">item.oemPartNumber</TableCell>
</TableRow>
))
</TableBody>
Second question
To extract only a given variable out of a JSON, you can use deconstruction and then use the deconstructing operator ... to get everything lefy of your object in a variable, here named newData :
removemsg()
const data = = this.props
const validationMessage, ...newData = data
console.log(newData)
However, you cannot directly modify your props.
answered Mar 6 at 14:49
TreycosTreycos
4,44821433
4,44821433
add a comment |
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%2f55024416%2fhow-to-render-grand-child-and-remove-json-object%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