Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda