-1
I have the following JSON
{
"navigator.zoom.in": "Zoom +",
"navigator.zoom.out": "Zoom -",
"badge_name_BR263": "GAMES 6!",
"badge_name_BR264": "4Anos",
"badge_name_X2046": "Cabana Aconchegante",
"badge_desc_X2046": "Duis interdum viverra ante at hendrerit!",
"badge_name_HBC049": "Solstício de Natal",
"badge_desc_HBC049": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellu tincidunt!",
"badge_name_RHBT102": "Suspendisse nec",
"badge_desc_RHBT102": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellu",
"badge_name_RHBT103": "Especial de Natal",
"badge_desc_RHBT103": "Ho, ho, ho... Feliz Natal! Duis interdum viverra ante at hendrerit. Integer elementum tortor!",
"badge_name_X2047": "Suspendisse nec",
"badge_desc_X2047": "Lorem ipsum dolor sit amet, consectetur adipiscing elit phasellu tincidunt!",
"navigator.searchcode.title.popular": "Popular",
"navigator.searchcode.title.chat_chill_discussion": "Conversas",
"navigator.searchcode.title.games_events": "Jogos"
}
first need to filter only the badge_name
and badge_desc
, I was able to filter as follows
const str = JSON.stringify(json);
const match = str.match(/"badge_(name|desc)_(\w+)":"(.*?)"/g).reverse();
now I need a way to extract the code after the _
and then join the badges that have the same code, and if n has been separated, for example
//output
Código: X2047
Titulo: Suspendisse nec
Descrição: Lorem ipsum dolor sit amet, consectetur adipiscing elit phasellu tincidunt!
...
Código: BR264
Titulo: 4Anos
Descrição: Sem descrição
I think I’ll have to go through one for of
but I don’t know how to get this data, I’m grateful who can help
maybe you need to make a
map/reduce
of this object to form a new object, see the answers of this question that can help you: https://answall.com/questions/493586/howto travel through a-array-objects-somar-propriedades-espec%C3%adficas-e-unify-es– Ricardo Pontual