Recent

Author Topic: TJSONObject : Whether objects can be directly transferred to json  (Read 716 times)

Jzhen

  • New Member
  • *
  • Posts: 23
Quote
   Student student = new Student();
   student.setId(1);
   student.setAge("20");
   student.setName("jno");
   System.out.println(JSON.toJSON(student));
 
   String stuString = JSONObject.toJSONString(student);

jsonObject.ToString or jsonObject.ToJSON cannot implement such conversion. What should i do?

paweld

  • Hero Member
  • *****
  • Posts: 970
Best regards / Pozdrawiam
paweld


Jzhen

  • New Member
  • *
  • Posts: 23
Re: TJSONObject : Whether objects can be directly transferred to json
« Reply #3 on: February 10, 2023, 03:57:43 am »
https://wiki.lazarus.freepascal.org/Streaming_JSON

This is a record. Can it be implemented without changing the data type? I think it needs to inherit TPersistent. This modification may not be accepted by the company.



 

TinyPortal © 2005-2018