|
@@ -283,6 +283,8 @@ Type
|
|
function GetAsJSON: TJSONStringType; override;
|
|
function GetAsJSON: TJSONStringType; override;
|
|
function GetAsString: TJSONStringType; override;
|
|
function GetAsString: TJSONStringType; override;
|
|
procedure SetAsString(const AValue: TJSONStringType); override;
|
|
procedure SetAsString(const AValue: TJSONStringType); override;
|
|
|
|
+ Public
|
|
|
|
+ Class var StrictEscaping : Boolean;
|
|
public
|
|
public
|
|
Constructor Create(const AValue : TJSONStringType); reintroduce;
|
|
Constructor Create(const AValue : TJSONStringType); reintroduce;
|
|
Constructor Create(const AValue : TJSONUnicodeStringType); reintroduce;
|
|
Constructor Create(const AValue : TJSONUnicodeStringType); reintroduce;
|
|
@@ -588,7 +590,7 @@ Type
|
|
Function SetJSONInstanceType(AType : TJSONInstanceType; AClass : TJSONDataClass) : TJSONDataClass;
|
|
Function SetJSONInstanceType(AType : TJSONInstanceType; AClass : TJSONDataClass) : TJSONDataClass;
|
|
Function GetJSONInstanceType(AType : TJSONInstanceType) : TJSONDataClass;
|
|
Function GetJSONInstanceType(AType : TJSONInstanceType) : TJSONDataClass;
|
|
|
|
|
|
-Function StringToJSONString(const S : TJSONStringType) : TJSONStringType;
|
|
|
|
|
|
+Function StringToJSONString(const S : TJSONStringType; Strict : Boolean = False) : TJSONStringType;
|
|
Function JSONStringToString(const S : TJSONStringType) : TJSONStringType;
|
|
Function JSONStringToString(const S : TJSONStringType) : TJSONStringType;
|
|
Function JSONTypeName(JSONType : TJSONType) : String;
|
|
Function JSONTypeName(JSONType : TJSONType) : String;
|
|
|
|
|
|
@@ -662,7 +664,7 @@ begin
|
|
Result:=DefaultJSONInstanceTypes[AType]
|
|
Result:=DefaultJSONInstanceTypes[AType]
|
|
end;
|
|
end;
|
|
|
|
|
|
-function StringToJSONString(const S: TJSONStringType): TJSONStringType;
|
|
|
|
|
|
+function StringToJSONString(const S: TJSONStringType; Strict : Boolean = False): TJSONStringType;
|
|
|
|
|
|
Var
|
|
Var
|
|
I,J,L : Integer;
|
|
I,J,L : Integer;
|
|
@@ -683,7 +685,10 @@ begin
|
|
Result:=Result+Copy(S,J,I-J);
|
|
Result:=Result+Copy(S,J,I-J);
|
|
Case C of
|
|
Case C of
|
|
'\' : Result:=Result+'\\';
|
|
'\' : Result:=Result+'\\';
|
|
- '/' : Result:=Result+'\/';
|
|
|
|
|
|
+ '/' : if Strict then
|
|
|
|
+ Result:=Result+'\/'
|
|
|
|
+ else
|
|
|
|
+ Result:=Result+'/';
|
|
'"' : Result:=Result+'\"';
|
|
'"' : Result:=Result+'\"';
|
|
#8 : Result:=Result+'\b';
|
|
#8 : Result:=Result+'\b';
|
|
#9 : Result:=Result+'\t';
|
|
#9 : Result:=Result+'\t';
|
|
@@ -1087,7 +1092,7 @@ begin
|
|
if (I>0) then
|
|
if (I>0) then
|
|
W(',');
|
|
W(',');
|
|
W('"');
|
|
W('"');
|
|
- W(StringToJSONString(O.Names[i]));
|
|
|
|
|
|
+ W(StringToJSONString(O.Names[i],False));
|
|
W('":');
|
|
W('":');
|
|
O.Items[I].DumpJSON(S);
|
|
O.Items[I].DumpJSON(S);
|
|
end;
|
|
end;
|
|
@@ -1304,7 +1309,7 @@ end;
|
|
|
|
|
|
function TJSONString.GetAsJSON: TJSONStringType;
|
|
function TJSONString.GetAsJSON: TJSONStringType;
|
|
begin
|
|
begin
|
|
- Result:='"'+StringToJSONString(FValue)+'"';
|
|
|
|
|
|
+ Result:='"'+StringToJSONString(FValue,StrictEscaping)+'"';
|
|
end;
|
|
end;
|
|
|
|
|
|
function TJSONString.GetAsString: TJSONStringType;
|
|
function TJSONString.GetAsString: TJSONStringType;
|