Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
JSON weird format access data

This is a JSON snip that is created in WooCommerce by a plugin that adds some metadata. I cannot change the formatting of this JSON because it is generated by a plugin. The problem is that the keys and the values are added in a weird way. I am iterating through the line_items and statically referencing this data which I don't want to do, I would like to know if there is a smart way to reference for example: "key": "_cpo_product_id", "value": "3572", if this was formatted correctly it would be: "_cpo_product_id": "3572" and not have "value" as a key, and it would be accessed by: foo.line_items[i]._cpo_product_id but with this configuration I am a bit lost, I am sure there is an easy way to find the value for a specific key. I am doing this on Google app scripts, but a solution in JavaScript should suffice.

JSON snip:

"line_items": [
        {
            "id": 749,
            "name": "Dune",
            "product_id": 3572,
            "variation_id": 0,
            "quantity": 1,
            "tax_class": "",
            "subtotal": "149.54",
            "subtotal_tax": "31.40",
            "total": "149.54",
            "total_tax": "31.40",
            "taxes": [
                {
                    "id": 24,
                    "total": "31.403148",
                    "subtotal": "31.403148"
                }
            ],
            "meta_data": [
                {
                    "id": 11919,
                    "key": "_cpo_product_id",
                    "value": "3572",
                    "display_key": "_cpo_product_id",
                    "display_value": "3572"
                },
                {
                    "id": 11920,
                    "key": "_add-to-cart",
                    "value": "3572",
                    "display_key": "_add-to-cart",
                    "display_value": "3572"
                },
about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda