0

how it's possible to change the object like this:

data() .... emojiList: [];

methods: {
  //Generated by JSON file
  //{"sweat_smile":"😅","laughing":"😆","satisfied":"😆","innocent":"😇","smiling_imp":"😈","wink":"😉"};

  var emoji = emoji.emoji;

  this.emojiList = emoji;
}

but when I render only get the value, I'd like to make a new array with the previews, where I can set

{"name":"smile", "icon":"😅"}

can anybody understand me?

1 Answer 1

2

if your input is

{"sweat_smile":"😅","laughing":"😆","satisfied":"😆","innocent":"😇","smiling_imp":"😈","wink":"😉"}

then you can simply do:

var input = { "sweat_smile":"😅", "laughing":"😆", "satisfied":"😆", "innocent":"😇", "smiling_imp":"😈", "wink":"😉" }

var output = []

Object
  .keys(input)
  .forEach(k => { 
     output.push({ name: k, icon: input[k] })
  })

console.log(JSON.stringify(output, null, 4))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.