arakelian / java-jq

Lightweight Java wrapper around JQ, a flexible JSON processor available for multiple platforms
MIT License
82 stars 10 forks source link

Unable to work with empty input #14

Open alfonz19 opened 3 years ago

alfonz19 commented 3 years ago

JQ can be ran without input, say to use template to construct output out of nothing. Say that you pass parameter, and base on this parameter (this isn't probably supported yet) there will be array of N items generated.

But passing null is not supported and catched here:

com.arakelian.jq.ImmutableJqRequest.Builder#input

and passing empty string will fail later on here:

com.arakelian.jq.JqRequest#parse(com.sun.jna.Pointer, com.sun.jna.Pointer, java.lang.String, com.arakelian.jq.ImmutableJqResponse.Builder)

in memory instantiation:

final Memory memory = new Memory(input.length);
memory.write(0, input, 0, input.length);

My usecase is very simple, I'm writing just some helper tool, so I can bypass it (still via some unconvenient ways), but it would be great it this can be supported.