2

I'm getting a JSON response as follows :-

tthis.selectedRecord {"Id":"01t5C000002xxx","Name":"xxxES"},wanted to know how do i get the value of ID & Name separately.

2
  • 1
    What have you tried? Being that JSON stands for JavaScript Object Notation, and the controller for LWC is, in fact, JavaScript...there shouldn't be any parsing required. Just use it as you would any other JavaScript object...
    – Derek F
    Jun 16, 2019 at 14:12
  • I tried JSON.stringify(this.selectedRecord) - which is giving me the value of ID & Name {"Id":"01t5C000002xxx","Name":"xxxES"}. I want the value of the Id so that i can save this record as a look up.
    – Sunil
    Jun 16, 2019 at 14:49

1 Answer 1

6

Based on your comment, it sounds like you already have a native JavaScript object; no parsing is required:

console.log(this.selectedRecord.Id);
console.log(this.selectedRecord.Name);

Make sure you pay attention to the capitalization of the variables; Name is different than name.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .