Lazarus

Programming => General => Topic started by: Jzhen on February 09, 2023, 10:04:58 am

Title: TJSONObject : Whether objects can be directly transferred to json
Post by: Jzhen on February 09, 2023, 10:04:58 am
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?
Title: Re: TJSONObject : Whether objects can be directly transferred to json
Post by: paweld on February 09, 2023, 10:44:38 am
https://wiki.lazarus.freepascal.org/Streaming_JSON
Title: Re: TJSONObject : Whether objects can be directly transferred to json
Post by: PierceNg on February 09, 2023, 11:58:15 am
https://wiki.freepascal.org/LGenerics#Exporting_structures_to_JSON_format
Title: Re: TJSONObject : Whether objects can be directly transferred to json
Post by: Jzhen 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.

Title: Re: TJSONObject : Whether objects can be directly transferred to json
Post by: Jzhen on February 10, 2023, 04:12:50 am
https://wiki.freepascal.org/LGenerics#Exporting_structures_to_JSON_format


I still view it in the watch list
TinyPortal © 2005-2018