First of all, thank you guys for the excellent plugin.
I've just installed a trial version and I'm almost sure that this plugin is exactly what I was looking for.
I still have one question.
According to PocketQuery documentation my REST service has to return an array. But sometimes I want to load and render a more complicated structure.
For example, my REST API returns an object with two fields:
{ paging: ..pagination data object.. content: ..result array.. }
I can render a data table by specifying JSON Path as "$.content" or using a custom converter. But I can't access "paging" object to extract paging.totalCount value. I know there is a rawResult variable defined, but it seems that rawResult is typed as java.lang.Object, and it's imposible to cast this variable to something like Map from velocity context. Any suggestions?
Hi Max,
Thank you for your interest in PocketQuery! It's a very valid question! I'll try to explain from a more technical point of view: the way how PocketQuery deals with results after they were fetched is the specific data the array-of-objects style data structure that the results from your REST API should look like. When we developed 3.0, we were searching for a way to make this a convention, so we could handle all kinds of data sources (also: the results from SQL databases always look like this data structure using the libraries we use). So our decision was that also the results from REST APIs should be converted into this data structure. But the problem is that we can never know what the results from REST APIs will look like - the structure can be arbitrary.
That's why we came of with the idea of converters. The idea of a converter: it receives the raw results from the data source as input and returns the result in a format as we need it. So if you have your results in the format you describe, you'll have to write your own converter.
Converters look like this:
function convert(json) { }
The json argument in that function is the json result retrieved from your data source using the given JSON Path ($.content) in your case. Now you need to parse this JSON string, convert it into an array-of-objects structure (with the column names as property keys) and return that structure.
For further information, please check our docs on converters.
Best, Felix
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.