File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ object MainForm: TMainForm
123123 '"'
124124 ''
125125 'See also the possibilities in the MenuBar')
126+ OnChangeTracking = MemoJSONChangeTracking
126127 Align = Client
127128 Size.Width = 613.000000000000000000
128129 Size.Height = 355.000000000000000000
Original file line number Diff line number Diff line change @@ -74,10 +74,14 @@ TMainForm = class(TForm)
7474 procedure Label1Click (Sender: TObject);
7575 procedure ActionList1Update (Action: TBasicAction; var Handled: Boolean);
7676 procedure EditClassNameChange (Sender: TObject);
77+ procedure MemoJSONChangeTracking (Sender: TObject);
78+ private type
79+ TValidationTypes = (vtUnchecked, vtValid, vtInvalid);
7780 private
7881 { Private declarations }
7982 FCheckVersionResponse: TRelease;
8083 FJsonMapper: TPkgJsonMapper;
84+ FIsValid: TValidationTypes;
8185 public
8286 { Public declarations }
8387 end ;
@@ -211,10 +215,20 @@ procedure TMainForm.ActionList1Update(Action: TBasicAction; var Handled: Boolean
211215 if not OutputFormatDict.TryGetValue(TabControl1.ActiveTab, OutputFormat) then
212216 OutputFormat := nil ;
213217
214- actConvert.Enabled := FJsonMapper.IsValid(MemoJSON.Text.Trim);
218+ if FIsValid = vtUnchecked then
219+ if FJsonMapper.IsValid(MemoJSON.Text.Trim) then
220+ FIsValid := vtValid
221+ else
222+ FIsValid := vtInvalid;
223+ actConvert.Enabled := FIsValid = vtValid;
215224 actSaveAs.Enabled := (OutputFormat <> nil ) and (actConvert.Enabled);
216225end ;
217226
227+ procedure TMainForm.MemoJSONChangeTracking (Sender: TObject);
228+ begin
229+ FIsValid := vtUnchecked;
230+ end ;
231+
218232procedure TMainForm.actOnlineValidationExecute (Sender: TObject);
219233const
220234 JsonValidatorUrl = ' https://jsonformatter.curiousconcept.com/?data=%s&process=true' ;
Original file line number Diff line number Diff line change @@ -268,8 +268,13 @@ function TPkgJsonMapper.GetJsonType(aJsonValue: TJsonValue): TJsonType;
268268end ;
269269
270270function TPkgJsonMapper.IsValid (aJsonString: string): boolean;
271+ var
272+ Value : TJSONValue;
271273begin
272- Result := TJSONObject.ParseJSONValue(aJsonString) <> nil ;
274+ Value := TJSONObject.ParseJSONValue(aJsonString);
275+ Result := Value <> nil ;
276+ if Result then
277+ Value .Free;
273278end ;
274279
275280function TPkgJsonMapper.LoadFormFile (aJsonFile: string): TPkgJsonMapper;
You can’t perform that action at this time.
0 commit comments