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

223
Views
Cómo verificar si existe una clave en Json Object y obtener su valor

Digamos que este es mi JSON Object

 { "LabelData": { "slogan": "AWAKEN YOUR SENSES", "jobsearch": "JOB SEARCH", "contact": "CONTACT", "video": "ENCHANTING BEACHSCAPES", "createprofile": "CREATE PROFILE" } }

Necesito saber si el 'video' existe o no en este objeto, y si existe, necesito obtener el valor de esta clave. Intenté seguir, pero no puedo obtener el valor de esta clave.

 containerObject= new JSONObject(container); if(containerObject.hasKey("video")){ //get Value of video }
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Use el código a continuación para encontrar la clave si existe o no en JsonObject . El método has("key") se usa para encontrar claves en JsonObject .

 containerObject = new JSONObject(container); //has method if (containerObject.has("video")) { //get Value of video String video = containerObject.optString("video"); }

Si está utilizando optString("key") para obtener el valor de String, no se preocupe si las claves existen o no en el JsonObject .

over 4 years ago · Santiago Trujillo Report

0

Usar:

 if (containerObject.has("video")) { //get value of video }
over 4 years ago · Santiago Trujillo Report

0

containerObject = new JSONObject(container); if (containerObject.has("video")) { //get Value of video }
over 4 years ago · Santiago Trujillo 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!