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

182
Vistas
Get data from RichSnippet JSON and set the same string into other variable

I have this JSON generated from external (Reviews-io) script: https://widget.reviews.co.uk/rich-snippet/dist.js

    richSnippet({

        store: "www.storedigital.local",
        sku:"6647;6647_5;6647_4;6647_3;6647_11;6647_10;6647_2;6647_1;6647_9;6647_8;6647_7;6647_6",
        data:{
          "url": "store.stg.gsd.local/1/silla-replica-eames.html",
          "description": ``,
          "mpn": "6647",
          "offers" :[{
            "@type":"Offer",
            "availability": "http://schema.org/InStock",
            "price": "559",
            "priceCurrency": "MXN",
            "url": "https://store.stg.gsd.localx/1/silla-replica-eames.html",
            "priceValidUntil": "2022-05-26",
          }],
          "brand": {
           "@type": "Brand",
           "name": "Not Available",
         }
        }

    })

I need to get all the string of numbers in "sku", and then put them in another variable as same format (6647; 6647_1; 6647_2)

I try to get the numbers using this JS but doesn't works

var skucollection = JSON.parse(richSnippet, function (key, value) {
   if (key == "sku") {
     return new Sku(value);
    } else {
     return value;
    }
});

Can you help me check what I am doing wrong, to get this sku's value string, please?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

JSON.parse is not too much? ,handle it as it is internally (a JSON indeed)

var richSnippet = {
  store: 'www.storedigital.local',
  sku: '6647;6647_5;6647_4;6647_3;6647_11;6647_10;6647_2;6647_1;6647_9;6647_8;6647_7;6647_6',
  algomas: [],
  data: {
    url: 'store.stg.gsd.local/1/silla-replica-eames.html',
    description: ``,
    mpn: '6647',
    offers: [
      {
        '@type': 'Offer',
        availability: 'http://schema.org/InStock',
        price: '559',
        priceCurrency: 'MXN',
        url: 'https://store.stg.gsd.localx/1/silla-replica-eames.html',
        priceValidUntil: '2022-05-26',
      },
    ],
    brand: {
      '@type': 'Brand',
      name: 'Not Available',
    },
  },
};
var test;
Object.keys(richSnippet).forEach((key) => {
  if (key == 'sku') {
    test = richSnippet[key];
  }
});

console.log('test', test);

about 4 years ago · Juan Pablo Isaza Denunciar
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