How to get json inside json

{
user” :{
“class” : “12345”,
“title” : “Portugal vs. Denmark”,
“content_available” : true,
“priority” : “high”
}
}

i want to get the “class” inside the “user” object
how do i do this? i wanna put it in .ts file

with dots for example

 {a: {b: {c: 'test'}}}}

could be

a.b.c

let say your object name is something

let something: any = {
 user :{
 class : “12345”,
 title : “Portugal vs. Denmark”,
 tcontent_available : true,
 priority : “high”
 }
 }

then

 something.user.class

if you want to declare interfaces, for example

 export interface UserDetail {
      class: string;
      title: string;
      content_available: boolean; 
      priority: string;
}

export interface User {
     user: UserDetail;
 }

then

let something: User =  {
 user :{
 class : “12345”,
 title : “Portugal vs. Denmark”,
 content_available : true,
 priority : “high”
 }
 }
1 Like