On 30/05/15 05:48, Michael Van Canneyt wrote:


On Fri, 29 May 2015, "Leonardo M. Ramé" wrote:

Hi, does anyone know if when adding a base64 encoded string to an
TJsonObject and calling AsJson method, the base64 is broken?

Normally not.

I did try to decode (with base64 -d command) and I'm getting errors
when trying to decode the base64 string contained in the json. Btw,
this is the 1nst time I get errors, the file encoded is about 1.5mb.

If you write the json with AsJSON to file and try to decode this file,
that will obviously not work.
You need to get the value of the member with the base64 using the
AsString method. The result of AsString should be decodable

I have used JSON with Base64 repeatedly and never had problems.

Michael.



Michael, obviously I decode the value of the member. Anyway, in this particular case using AsJson the result is broken some way.

I just concatenated a string like:

myString := '{ "var1": "' + Base64EncodedString + '" }';

And it worked perfectly, while doing:

myJson.Add('var1', Base64EncodedString);

and

myJson.AsJson results in errors while trying to decode "var1".


--
Leonardo M. Ramé
http://leonardorame.blogspot.com

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to