Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Obtenga datos de RichSnippet JSON y establezca la misma cadena en otra variable

Tengo este JSON generado a partir de un script externo (Reviews-io): 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", } } })

Necesito obtener toda la cadena de números en "sku" y luego ponerlos en otra variable con el mismo formato (6647; 6647_1; 6647_2)

Intento obtener los números usando este JS pero no funciona

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

¿Puede ayudarme a verificar qué estoy haciendo mal para obtener la cadena de valor de este sku, por favor?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

JSON.parse no es demasiado? , manejarlo como es internamente (un JSON de hecho)

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!