Skip to content

Commit

Permalink
included compatibility with Delphi XE3 or superior
Browse files Browse the repository at this point in the history
  • Loading branch information
johnidm committed Oct 21, 2013
1 parent 9b27643 commit e91d59b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions bsonUtils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,21 @@ function BsonToJson(Doc:IBSONDocument):WideString;
stack[stackIndex].al:=VarArrayHighBound(stack[stackIndex].a,1)+1;
stack[stackIndex].isDoc:=true;
Result:='';//TODO: TStringBuilder

{$if CompilerVersion >= 17}
ods:= FormatSettings.DecimalSeparator;
{$else}
ods:=DecimalSeparator;
{$ifend}

try

{$if CompilerVersion >= 17}
FormatSettings.DecimalSeparator:='.';
{$else}
DecimalSeparator:='.';
{$ifend}

firstItem:=true;
Result:=Result+'{';
while stackIndex<>-1 do
Expand Down Expand Up @@ -235,7 +247,13 @@ function BsonToJson(Doc:IBSONDocument):WideString;
end;
end;
finally

{$if CompilerVersion >= 17}
FormatSettings.DecimalSeparator:=ods;
{$else}
DecimalSeparator:=ods;
{$ifend}

end;
end;

Expand Down Expand Up @@ -433,9 +451,21 @@ procedure JsonIntoBson(const jsonData:WideString; doc:IBSONDocument;
al:=0;
InObjectOrArray:=true;
firstItem:=true;

{$if CompilerVersion >= 17}
ods:= FormatSettings.DecimalSeparator;
{$else}
ods:=DecimalSeparator;
{$ifend}

try

{$if CompilerVersion >= 17}
FormatSettings.DecimalSeparator:='.';
{$else}
DecimalSeparator:='.';
{$ifend}

d:=doc;
//main loop over key/values and nested objects/arrays
while (i<=l) and (stackIndex<>-1) do
Expand Down Expand Up @@ -646,7 +676,13 @@ procedure JsonIntoBson(const jsonData:WideString; doc:IBSONDocument;
if stackIndex<>-1 then raise EJsonDecodeException.Create(
'JSON with '+IntToStr(stackIndex+1)+' objects or arrays not closed');
finally

{$if CompilerVersion >= 17}
FormatSettings.DecimalSeparator:=ods;
{$else}
DecimalSeparator:=ods;
{$ifend}

end;
end;

Expand Down

0 comments on commit e91d59b

Please sign in to comment.