How do I convert a string from example: 'person.name' to an object property - person.name?
Asked
Active
Viewed 259 times
1 Answers
0
Use **JSON.parse(obj)** ;
1)create model
export class Person{
name:string;
age :number;
}
2) getting your response string
res="{"name":"john","age":22}" ;
3)create object
person :Person ;
4)this.person= <Person> JSON.parse(this.res);

Shubham Manmode
- 3
- 1