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

128
Views
duplicate entries in JSON

I've this JSON:
JSON

I don't want this duplicates, I can I fix my code?

 let caratteristiche = html.match(/<table width="100%">(.*?)<\/table>/mi);

if (caratteristiche) {
    for (let el of caratteristiche) {
        let element = el.match(/<span class="OD_(red|blue)">(.*?)<\/span><\/td>/mig)

        if (element && element.length > 0) {
            // <span class="OD_blue">Climatizzazione</span></td>
            // <span class="OD_blue">Impianti Gas</span></td>
            for (let elem of element) {
                try {
                    let item = elem.match(/<span class="OD_(red|blue)">(.*?)<\/span><\/td>/i);
                    obj.caratteristiche.push(item[2])
                } catch (e) {
                    //
                }
            }
        } else {
            obj.caratteristiche = null
        }
    }
}

this is my caratteristiche:

Array(2) [<…an="2" class="OD_last_row_red">, <td class="OD_ba…td colspan="2" class="OD_last_row_red">, 1335, <img class="OD_img_omb…an="2" class="OD_last_row_red">, undefined]

and this element that i cycle on it to scrape only text between html tags

Array(6) [Climatizzazione, Impianti Gas, Installazione Ganci traino, Navigatori Autoradio, Pre-revisioni, Consegna a domicilio]

element

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

0

There are several ways of removing duplicates in arrays.

let chars = ['A', 'B', 'A', 'C', 'B'];
let uniqueChars = [...new Set(chars)];

or

let uniqueChars = chars.filter((c, index) => {
    return chars.indexOf(c) === index;
});
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!