JsonToDelphi icon indicating copy to clipboard operation
JsonToDelphi copied to clipboard

How to hide TJsonOptions

Open megatkurniawan opened this issue 9 months ago • 2 comments

if i request AsJson from class, then i will get json response with TJsonOption. how to remove it?

{ "id": "6", "data": "Test" "options": [ "joDateIsUTC", "joDateFormatISO8601" ] }

megatkurniawan avatar Feb 14 '25 07:02 megatkurniawan

+1 on this. Novice with the classes, used once, got this tagged on the end, hand built other results due to this.

jasonjac2 avatar Feb 14 '25 08:02 jasonjac2

need send json to client server which should not have any fields other than those specified. so currently I am using this method.

var JSONObject: TJSONObject; begin JSONObject := TJSONObject.ParseJSONValue(JSonString) as TJSONObject; try JSONObject.RemovePair('options'); Result := JSONObject.ToString; finally JSONObject.Free; end; end;

megatkurniawan avatar Feb 14 '25 08:02 megatkurniawan

@megatkurniawan if you are facing this issue in delphi 12 then this is the solution

Image

leufmt avatar Jul 11 '25 17:07 leufmt