You are not logged in.
I think this replace will be safer if you consider only #13 as a line break as well.
pdf := docs._[i].S['pdf']; pdf := StringReplaceAll(pdf, #13#10, ''); pdf := StringReplaceAll(pdf, #13, '');NOTE: The order matters. You should replace #13#10 first, and then #13
Thank you too. But I chose Arnaud's tip because it's cleaner.
That is it, TrimControlChars(), worked.
I didn't know about this function thank you.
But, just thinking, if the data that I've provided is considered valid, shouldn't we add a TrimControlChars() call in Base64 functions before conversion?
I've asked the guy and we tested using Java.util (built-in) and Apache commons. Both add line feed in the output...
If it can helps, here an example how Synapse do this parser -> https://github.com/marado/synapse/blob/ … e.pas#L172
Of course I've test and it still doesn't working. ![]()
pdf := StringReplaceAll(docs._[i].S['pdf'], #13#10, '');
//FileFromString(DecodeBase64(pdf), fn, True);
FileFromString(Base64ToBin(pdf), fn, True);The other system, made in Java, uses a known lib (Apache, I think) to encode in Base64... So, I think it's a valid parser and because that I cannot ask them to change it. ![]()
Is it possible to implement a workaround in mORMot?
Could you put the input text into a gist so that we reproduce it?
I couldn't send the private PDF so, I asked the other part to make a fake one.
Here https://gist.github.com/mdbs99/fb6ddf23 … 2fff7a82f7
The structure is:
<Parametros>
<docs>
<doc>
<nome>filename</nome>
<pdf>base64</pdf>
...
</Parametros>Hi,
I have a system that is compiled on Delphi 7 using mORMOt (last commit 1dee1951016b9ab7 in 2020-03-29).
The system receives an XML which has some PDF encoded in Base64. These PDF are stored in a TDocVariantData structure. Later, it is read in some form to show PDF's for user.
To show a PDF I need to save as a file, in temporary directory. My issue is that I cannot decode Base64 just using Base64Bin() function, but it works using the (old) Synapse lib. But I would like to rip of this lib for use just mORMot.
Consider this:
var
i: Integer;
fn: TFileName;
pdf: RawByteString;
begin
{...}
{ docs is a TDocVariantData...}
for i := 0 to docs.Count-1 do
begin
{find the correct PDF selected by user...}
pdf := docs._[i].S['pdf'];
// FileFromString(DecodeBase64(pdf), fn, True); //<< this works
FileFromString(Base64ToBin(pdf), fn, True); // << this does not
ShellExecute(fn); // starts Adobe PDF
end;
end;- synacode.DecodeBase64() from Synapse reads perfectly
- XML looks like UTF8
- I've tried to make some conversions, like UTF8ToString / StringToUF8, SynUnicodeTo ... etc, but in vain.
Any ideas?
best regards.
The unit is stand alone so it works with mormot 1.18 too.
Sure. But in that transition to 2.0, would be nice to have a batch script to copy this unit from 2.0 to 1.8 — renamed, following unit name pattern of 1.8, I presume.
That is good.
I agree about almost all, especially about 2.2 — even it is easy using only one unit like SynCommons with "all included", it could be difficult to maintain the code because its size and bugs on IDE.
About 2.4, Although, I completely agree to focus on FPC as main target, I'm concerned about Delphi 7 compatibility, as I still have some systems on it. ![]()
Last time I checked, any attempt to provide some alternate asm to FPC x86_64 RTL (by Johannes IIRC) was a more or less rejected, for several reasons I don't remember well.
I think they don't like code that may not work in all platforms which FPC cover.
Ops! the JSON was wrong, they changed but I forgot to change on the code... f*ck!
Thank you!!
Hello,
I'm trying to serialize a JSON into record with nested one, but RecordLoadJSON returns FALSE.
JSON (body.json file) is like this:
{
"integrationId":19,
"token":{
"accessToken":"eyJhbGciOiJSUzI1NiIsInR5c",
"createdIn":"2020-01-21 09:28:44",
"expiresIn":"2024-12-25 09:28:44"
},
"success":true,
"message":null
}Then, I have TTokenResponse and TLoginResponse:
type
TTokenResponse = packed record
accessToken: RawUTF8;
createdIn: TDateTime;
expiresIn: TDateTime;
end;
TLoginResponse = packed record
integrationId: Integer;
token: TTokenResponse;
sucess: boolean;
message: RawUTF8;
end;
initialization
TTextWriter.RegisterCustomJSONSerializerFromText([
TypeInfo(TTokenResponse), 'accessToken:RawUTF8 createdIn,expiresIn:TDateTime',
TypeInfo(TLoginResponse), 'integrationId:Integer token:TTokenResponse sucess:boolean message:RawUTF8'
]);If I remove "success" field from both (JSON and record), it works.
I'm using last version of mORMot but compiling on Delphi 7.
For testing, could be like this:
function Login: TLoginResponse;
var
l: TRawUTF8List;
begin
RecordZero(result, TypeInfo(TLoginResponse));
l := TRawUTF8List.Create;
try
l.LoadFromFile('body.json');
if not RecordLoadJSON(result, l.Text, TypeInfo(TLoginResponse)) then
raise Exception.Create('Invalid...');
finally
l.Free;
end;
end;best regards.
Merry Christmas and a Happy New Year!
Hello,
Packages have been included and now I'm trying to add it in Online Package Manager (OPM).
I've already asked about the author but it seems that he has an issue to compile.
It looks like something related with the version. I'm using Lazarus 2.1.0 r59757M FPC 3.3.1.
Someone knows if we can compile mORMot using FPC 3.0.4, at least the base package?
If it's not possible now, can we make some changes to do it?
I think they only accepted packages that run in the current FPC version.
--
EDIT: he added, but is good to have it working on current version of FPC.
It solved. Thanks.
I have just one place, just one Synopse.inc.
Using `a71a5d9b84ad99448cde64396403290c00c196dc` (the previous one) works.
Please, what FPC/Laz revisions are you using on Windows?
I cannot compile from Github `dd5e00b89ba9f18a95c3e9eab1aa138da99a229f` (last commit in 1th August) in my environment: Lazarus 1.9.0 r58678M FPC 3.1.1 r39572 i386-win32-win32/win64
Message error in the subject.
I read "Release Notes-7.2.4-stable.pdf" and they wrote that we need to move on from ntwdblib.dll to ADO or FreeTDS, which is a old tech so, that is good.
I will ask them about these changes and tuning but one more question:
The SourceForge SVN is it currently compatible with FPC 3.0.4? I believe you can answer if you use MSSQL. I don't want to use a "non-updated-forked" branch which has some patches just for FPC... I would like to use the official one.
Thank you.
I'm a MSSQL user among 2008 and 2016 versions.
I would like to know which is the best option to use mORMot with this DBMS.
Nowadays, I have some systems that uses mssqlconn provides by FPC packages. The problem is that this implementation uses dblib.dll (I'm not thinking in Linux at this time) and in this link you can see that the last version is about the 2008 version (check dblib's download link).
I use a lot of Stored Procedures and this version doesn't work properly in many cases (eg. using XML stuff, try-catch inside SP's, etc). So, many times I need to ask to change the SP's implementation just because driver issues...
The second issue is about the dependency of this dblib.dll. I've heard that mORMot doesn't have any dependency (for all DBMS?) which is amazing for me. I could just deploy a new executable with no dependencies.
Finally, I know that mORMot developers like ZEOS lib as well, which could be an option too.
What do you recommend for a developer like me that uses FPC (last) and Lazarus (last) to build programs that could use the lasted version of MSSQL?
Thanks.
I believe you can use `SET NOCOUNT ON` before all these instructions.
Can SynPDF read/write digital signatures in PDF's?
I'm talking about this pattern -> https://www.adobe.com/content/dam/acom/ … sInPDF.pdf
(I changed my job, and we are focusing on FPC)
Good to know. ![]()
XML is too verbose and is such a mess, JSON is better.
Food for thought: http://jmespath.org/
It's not about verbosity or not. It's about integration with other systems.
As you can see above, there are some that think the same.
Hello Leslie7
Actually, FPC already has a XPATH implementation... but this project could be interesting. Thanks for the tip.
Then there is no problem to use the SOA of mORMot. Using SynOleDB for direct access to the MSSQL database.
But you can't use the ORM directly.
Understood ![]()
Touché!
Just like Pascal ![]()
Thanks. But, in my case, I'm referring about MS SQL Server.
I would like to access MS SQL directly and many tables, on a specific system, don't have ID as integer, only uniqueidentifier type as primary key.
Is it possible fake this ID by overriding some method?
It's early to say but, I'm thinking if `TID` could be a `Variant` instead of `Int64`. What do you think?
It's strange do not have anyone complain about missing XML.
Many companies use WebServices and XML is the mostly used.
That is a old thread, but I think this is the best place to ask:
If my table has only GUID/UUID primary key, how would be mORMot behavior, if there is not ID column at the physical table?
All right.
But, as I have many systems that works with XML, what is the simplest way to use mORMot to work with?
In mostly cases, I need to receive a XML, parse (using XPATH), create a new one, and send it back.
I mean, is that possible (and fast) to use some mORMot "XML to JSON" functions, parse the JSON, create a new one, and use "JSON to XML" to send it as XML at the end?
I know that is possible to work with XML instead JSON (see here). But is there an XPATH implementation to work with?
FPC has an implementation of XPATH but, it's based on WideString. I would like to know if we have a (fastest) implementation by Synopse, which works on Delphi and FPC.
Any input is welcome!
I've been thinking and my conclusion is the same as you had, I believe, years ago:
Even when packages provide a improvement at developing — simplifying the dependencies paths in user projects — it's simpler do not create packages in main source. Let this "specialization" to the users (developers) in their local computer.
I've tried to make a simple lib compatible with Delphi and Lazarus and it was a pain make changes in both source packages.
However, the new Online Package Manager for Lazarus won't work without a package. Tradeoffs...
Anyway, mORMot is changing my thoughts. Thanks for that.
I agree with you. It is more productive, but the debugger is a mile behind Delphi.
I've read that they are working in a new one (pure Pascal) but I don't know if they released some version.
So for us, packages are not convenient.
Indeed, I use more FPC/Lazarus for new projects than Delphi.
I have just one employer that still works with Delphi 7 and that is the version that I use.
Anyway, I like this simplest approach. But, I would like to understand the pros and cons.
I know it could be a pain to change every package version for each Delphi version —in Lazarus we need just one — but can't you see any pros?
I'm consider a old-school programmer.
Nowadays we see a lot of use of generics. I can't see a Java code that doesn't have generics.
My question is: We really need generics or we are just following other languages like Java or C#?
For me, most code that use generics are much more confuse. I think there is an abuse of generics.
We can live without them? What do you think?
Most Delphi/Lazarus projects have package(s). Why mORMot doesn't have?
Maybe Arnaud did not want manager a package for each Delphi version, as all developers do in most projects?
Having packages could improve the developing by just add it in the project, instead using paths.
In share projects — in a company — the library path should be the same if you're using just paths. But this could be a problem because some developers like to "install" their sources in different directories.
@ab
After 7 years, do you think Lazarus is better now? Do you use it?