Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

il_responseWriteStream returns incomplete JSON #106

Open
SteffenHaugeKtp opened this issue Aug 17, 2021 · 5 comments
Open

il_responseWriteStream returns incomplete JSON #106

SteffenHaugeKtp opened this issue Aug 17, 2021 · 5 comments

Comments

@SteffenHaugeKtp
Copy link

SteffenHaugeKtp commented Aug 17, 2021

I made a simple program that selects every from a file and returns it as JSON via noxDB.

Following the example file: noxdbcust.rpgle

`dcl-proc jsonTest;

dcl-pi *n;
    request  likeds(IL_REQUEST);
    response likeds(IL_RESPONSE);
end-pi;

dcl-s pResult pointer;

// Assume everything is OK
response.status = 200;
response.contentType = 'application/json';

// Use noxDB to produce a JSON resultset to return
pResult = json_sqlResultSet ('select * from MY_FILE');

// Use the stream to input data from noxdb and output it to ILEastic
il_responseWriteStream(response:json_stream(pResult));

end-proc;`

But it seems to return invalid JSON, it looks like its getting cut off at the end, sometimes?
It seems to occur if i select enough data from a single file.

If i use json_writejsonstmf to dump the data to a IFS file it's correct.

@NielsLiisberg
Copy link
Collaborator

Ok - so it seams like the stream-feature either on noxDb or in ILEastic is doing something "undocumented" ... I'll take a look. Thank you for the Feedback

@m1h43l
Copy link
Collaborator

m1h43l commented Oct 18, 2021

@SteffenHaugeKtp Could you tell us how "big" the data was which did get cut off when using il_responseWriteStream (how large was the IFS file)?

@SteffenHaugeKtp
Copy link
Author

I was selecting text from a DB2 file ie. SELECT text FROM db2_file LIMIT 1000

The problem seems to be øæå characters in the string field i select from.
If i change the first record in the DB2 to contain any of øæå characters and then do SELECT text FROM db2_file LIMIT 1
Then the http request returns 0 bytes.

But if i do the query with a sufficient big enough limit (100+) it returns some JSON but it's incomplete.

@m1h43l
Copy link
Collaborator

m1h43l commented Oct 21, 2021

@SteffenHaugeKtp What is the CCSID of the table and column and what is the CCSID of the job running the web service program?

@SteffenHaugeKtp
Copy link
Author

Everything is CCSID 277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants