Browse Source

* Fix bug #0035985

git-svn-id: trunk@42743 -
michael 6 years ago
parent
commit
a7880cbfab
2 changed files with 21 additions and 0 deletions
  1. 1 0
      packages/fcl-json/src/fpjson.pp
  2. 20 0
      packages/fcl-json/tests/testjsondata.pp

+ 1 - 0
packages/fcl-json/src/fpjson.pp

@@ -2497,6 +2497,7 @@ begin
       vtExtended   : Result:=CreateJSON(VExtended^);
       vtString     : Result:=CreateJSON(vString^);
       vtAnsiString : Result:=CreateJSON(UTF8Decode(StrPas(VPChar)));
+      vtUnicodeString: Result:=CreateJSON(UnicodeString(VUnicodeString));
       vtPChar      : Result:=CreateJSON(StrPas(VPChar));
       vtPointer    : If (VPointer<>Nil) then
                        TJSONData.DoError(SErrPointerNotNil,[SourceType])

+ 20 - 0
packages/fcl-json/tests/testjsondata.pp

@@ -238,6 +238,7 @@ type
     procedure TestCreateBoolean;
     procedure TestCreateBooleanUnquoted;
     procedure TestCreateObject;
+    procedure TestCreateJSONUnicodeString;
     procedure TestCreateJSONString;
     procedure TestCreateJSONStringUnquoted;
     procedure TestCreateJSONObject;
@@ -3926,6 +3927,25 @@ begin
   end;
 end;
 
+procedure TTestObject.TestCreateJSONUnicodeString;
+Const
+  A = 'A';
+  S : Unicodestring = 'A string';
+
+Var
+  O : TJSONObject;
+
+begin
+  O:=TJSONObject.Create([A,S]);
+  try
+    TestItemCount(O,1);
+    TestJSONType(O[A],jtString);
+    TestJSON(O,'{ "A" : "'+S+'" }');
+  finally
+    FreeAndNil(O);
+  end;
+end;
+
 procedure TTestObject.TestCreateNilPointer;
 
 Const