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

115
Views
devuelve la matriz json desde el controlador de primavera

Quiero regresar con mi controlador spring a JSONARRAY, pero al ejecutar recibo este error:

java.lang.IllegalArgumentException: No se encontró ningún convertidor para el valor de retorno de tipo: clase org.codehaus.jettison.json.JSONArray

este es mi codigo:

 @RequestMapping(value = "/generate", method = RequestMethod.GET) @ResponseBody public JSONArray generate() throws NoSuchFieldException, CloneNotSupportedException{ return facturationSvc.facturer(); }

NB: El método "facturer()" del servicio "facturationSvc", devuelve un JSON ARRAY

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Debe devolver una lista Java, no un JSONArray. Spring usa Jackson, y el propósito de jackson es convertir un objeto Java a/desde elementos base como JsonArray, y luego a Json String

No necesita administrar json directamente, Spring lo hace todo por usted, por lo que la solución aquí es cambiar sus tipos de devolución (del controlador y el servicio) y administrar solo objetos Java

 @RequestMapping(value = "/generate", method = RequestMethod.GET) @ResponseBody public List<YourFacturerClass> generate() { return facturationSvc.facturer(); }
about 4 years ago · Santiago Trujillo Report

0

deberías devolver una cadena, no JSONArray,

 String generate() throws NoSuchFieldException, CloneNotSupportedException{ return facturationSvc.facturer().toString(); }
about 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!