Home > Mobile >  show key instead the value json in vuejs
show key instead the value json in vuejs

Time:02-25

i have this data in json

    {
    name: "Contract information", 
    description: "Contract information", 
    created_at: "2021-08-23 09:40:42", 
    updated_at: "2021-08-23 09:41:07", 
    sender_id: 8, 
    chat: false, 
    videocall: false, 
    meeting: true
}

i want show in front end with vuejs the chat, videocall and meeting, but not true/false but the key (chat, videcall, meeting)

i tried to do this :

    <b-button variant="outline-primary my-2 mx-1" style="cursor: default">
            <strong> Contact:</strong>
            {{getConsultancy.meeting) }}
    </b-button>

but it show me the values true/false how can i do show only the key?

CodePudding user response:

I may have understood wrong but,

This code will give you real value keys but not the booleans

Object.keys(yourObject).filter(key => (typeof yourObject[key] != "boolean"))

Or If you just want to keys you can use

Object.keys(yourObject)

CodePudding user response:

To get the Key you can do it with Object.keys(getConsultancy) or Object.keys(getConsultancy.meeting)

See Docs here: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

  • Related