We have requirement to create ODATA supported Rest API. We will have to use Java and Mysql for this purpose. Data will be in JSON format which is dynamically changing and not possible to define the exact fields.
I'm looking at libraries like Apache Olingo for this. Documentation doesn't have that much of information about JSON support. Any thoughts on this is appreciated.
Apache Olingo is supporting JSON. It has a serializer for mapping from JSON - org.apache.olingo.server.core.serializer.json.ODataJsonSerializer.
But I'm not sure what do you mean by dynamically changing and not possible to define the exact fields. Do you want to use Open Types from OData? Unfortunately, I have no experience with them in Apacha Olingo.
Related
what is the best json to pojo generator which have oneof/allof/anyof features . We are currently using a custom one which doesn't support the latest additions in the json. I have tried some of them that shows in the google search but didn't work.
I use https://github.com/java-json-tools/json-schema-validator for schema validation and jackson for pojo-generator.
However, I did not find any support for allOf/AnyOf/oneOf explicitly in jackson. But jackson has a rich set of annotation and it can be built using those.
you can refer a discussion https://github.com/joelittlejohn/jsonschema2pojo/issues/392 to see if something helpful is there for you.
Currently I am using OData2 with java via apache olingo. As time changes, new requirement comes out, now we have dynamic attributes for complex type. We cannot know these attributes in advance to provide with metaData.
So far my reading, OData4 can provide openType = true and somehow like can provide dynamic attributes can provide.
I tried to upgrade Odata2 to Odata4, everything becomes RED. Seems like not compatible.
My database structure is open type.
Question:
Is there any way to achieve dynamic attribute in Odata2 without upgrading?
Any limitation for using Odata4?
The OData protocol has vast incompatible differneces between V2 and V4. That is why the Olingo libraries are incompatible as well.
Also dynamic properties are currently not implemented in the Olingo libraries. At the moment every payload is validated against the metadata. This is true for Olingo V2 and V4.
If you only want these dynamic properties to be in the payload as a workaround you can use your own deserializer and serializer. If you want to address these dynamic properties within the URL then there is no workaround as the URL is tightly checked against the metadata as well.
Using the SurveyMonkey API, I'm writing some Java code to do survey analysis. The survey monkey API returns JSON data. I would like to generate some Java classes so I get some type safety and conciseness while I'm manipulating the data. I've had no luck finding a json schema for the Survey Monkey API.
So, I'm looking into tools that generate a schema from json directly, but obviously that will be less desirable than getting it from the canonical source.
The question:
Can anyone recommend a tool-chain that will take me from a set of json examples to a set of java classes that can be used to read an manipulate that json. This might include the intermediate step of generating a schema, but the end-game I'm after is the classes.
If anyone knows of a schema for the API, though, that would be even better.
Why don't you go with polljoy, it's Opensource and I have already integreat it on one of my site and it's working perfectly, you can find it out one below menioned link.
Polljoy
I'm developing an application where I've requested data from an external institution's website. They have informed me that the data will be provided by OAI-PMH.
Could someone show me some sample code in Java how data is extracted from a OAI-PMH ?
I wonder how different it is from reading and parsing XML data.
Thank you.
Warmest wishes,
Shoubhik
For a Java implementation, for example, you could use some already existent library, like XOAI with an easy to use API. There are some provided samples.
To extract metadata from each Record you could use a XML Parser or a XML bind approach (JAXB). For other languages, like PHP and Perl there are also other alternatives.
Please bear with me for this novice question.
I am calling a RESTful web service APIs that returns XML response. Apart from normal XML parsing schemes like DOM based parsing, SAX based parsing, is there a way to transform this XML response directly into some object? What more details/specification from service side would be required to do such transformation?
i can't give a summary of all the options available, but i recently used jaxb to do the opposite (java to xml) and it was simple and easy to use. since jaxb also supports xml to java, as described here, i would suggest giving that a look. it's based on annotations and java beans (or pojos) - you just indicate which attributes correspond to the elements with attributions, and it does the rest.
if you have a schema, it will generate java classes for you. alternatively, here's an example of working without a schema.
ps according to comments in the final link, you don't even need to annotate if the names match the xml!