Просмотр исходного кода

* Add joIgnoreDuplicates

git-svn-id: trunk@45840 -
michael 5 лет назад
Родитель
Сommit
3d333a1d17
2 измененных файлов с 3 добавлено и 2 удалено
  1. 2 1
      packages/fcl-json/src/jsonparser.pp
  2. 1 1
      packages/fcl-json/src/jsonscanner.pp

+ 2 - 1
packages/fcl-json/src/jsonparser.pp

@@ -129,7 +129,8 @@ begin
   // Add to existing structural type
   if (FStruct is TJSONObject) then
     begin
-    TJSONObject(FStruct).Add(FKey,AValue);
+    if (Not (joIgnoreDuplicates in options)) or  (TJSONObject(FStruct).IndexOfName(FKey)=-1) then
+      TJSONObject(FStruct).Add(FKey,AValue);
     FKey:='';
     end
   else if (FStruct is TJSONArray) then

+ 1 - 1
packages/fcl-json/src/jsonscanner.pp

@@ -51,7 +51,7 @@ type
 
   EScannerError = class(EParserError);
 
-  TJSONOption = (joUTF8,joStrict,joComments,joIgnoreTrailingComma);
+  TJSONOption = (joUTF8,joStrict,joComments,joIgnoreTrailingComma,joIgnoreDuplicates);
   TJSONOptions = set of TJSONOption;
 
 Const