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

117
Views
Compruebe si el objeto JSON comienza con 'https' en JavaScript

Tengo urls como esta:

 data: { "zip": 442, "code": "AG", "capital": "london", "currency": { "code": "XCD", "name": "East" "link": "https://en.wikipedia.org/wiki/", "url": "https://en.wikipedia.org/" }

Quiero escribir una declaración if que verifique si el objeto comienza con 'https:' y luego decirle qué hacer.

Esto es lo que tengo, pero no hace que se pueda hacer clic en mis URL ni devuelve sus datos.

 if (jsonObject.startsWith("http://")) { const text = document.createElement("a"); k.textContent = jsonObject; k.setAttribute("href", jsonObject); j.appendChild(k);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Estás cerca, creo, simplemente no estás accediendo a los valores reales dentro del objeto.

Si desea verificar los valores de las propiedades del objeto y si comienzan con http/https, puede recorrer el objeto y usar la misma verificación.

 jsonObject.values.forEach((value) => { if(value.startsWith("https://") { const text = document.createElement("a"); k.textContent = value; k.setAttribute("href", value); j.appendChild(k); } });
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!