Caused by: org.springframework.data.mapping.model.MappingException: No mapping metadata found for java.lang.Object
at org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter.read(MappingCouchbaseConverter.java:140)
I am receiving this error when attempting to retrieve a document from my couchbase server. The document is a simple JSON object with a nested object inside as well as lists of JSON objects. I am able to get the document successfully when the document only contains the lists, but not when the nested object is present.
Do I have to define any nested object as a java class for couchbase and spring to cooperate, or am I missing something.
Related
Coming from this question: Conversion of XML Schema to JSON array list in Biztalk
We have the same situation: Our XML needs to be converted to JSON and we have child objects which can occur one or multiple times which must always result in a JSON array.
The problem is that we are not able to set a target namespace because our schema is generated by SAP (IDoc).
Are there other options to do the serialization? I would like to avoid a custom implementation for JSON serialization.
Create an internal BizTalk schema with a target namespace and map the SAP payload to that.
I have a topic that will be published with multiple types of JSON messages. I don't have control over the publisher code to add any headers etc. But, I want to leverage #KafkaHanlder to handle the different JSON messages inferred to the domain objects. I got some references https://github.com/spring-projects/spring-kafka/tree/master/samples/sample-02
As I don't have control over the publisher code, with the custom deserializer I want to handle multiple JSON types. Any references to write custom de-serializer to handle multiple JSON objects with #KafkaHandler.
You can't use class level listeners without deserialization. It's a catch-22.
To determine which method to call, we need to know the type (after deserialization); we can't infer the type if it hasn't been deserialized yet.
You could write a wrapper for muliple JSON deserializers, either using try...until success, or by "peeking" at the JSON to determine hueristically which deserializer to call for this record.
if (json.contains "\"foo\":") {
return deserializeWithFooDeser(data, headers);
}
I am trying to populate JSON response which includes embedded resources using Spring Hateoas framework.But I am getting empty "links" as part of my Json response. Unable to figure which part/module of the function is populating empty JSON field.
JSON class is extending Spring "Resource Support" class?
This problem is related to this other problem, but instead, I wish to convert a single model instance to JSON, using an existing Tastypie Resource.
Thanks to #grimygoop for the hint, I managed to create a method that can serialize any Django model instance to JSON using the associated Tastypie Resource. Here's how the procedure works...
def res_serialize(request, resource, obj):
data = resource.full_dehydrate(resource.build_bundle(obj=obj, request=request))
return resource.serialize(None, data, 'application/json')
To use this, you must have already defined a Resource class, and must also have a request object for this to work as expected. You'd then perform the serialization as such:
res_serialize(request,ClientResource(),client)
Note ClientResource() in the invocation above - we must pass the Resource instance, not just the class reference. So, in the above example, the object client gets serialized to JSON via the associated resource class. This can for example help in custom views where you wish to return a serialized instance of the object.
Also, a slight modification of this can handle querysets instead of single objects.
When I naively use Jackson to convert to JSON i receive this exception:
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.apache.cayenne.access.DefaultDataRowStoreFactory and no properties discovered to create BeanSerializer
Edit: I'd like to do something like this:
ObjectContext context = cayenneRuntime.newContext();
List<User> users = ObjectSelect.query(User.class).select(context);
JsonObject json = Json.mapper.convertValue(obj, Map.class)
Are there any existing solutions? Thanks
Considering that in a general case Cayenne gives you not just objects, but a virtual graph of objects, serialization to JSON becomes a more quirky topic than it initially appears.
The short answer: you'd have manually build JSON for whatever subgraph of your object graph.
While not a direct answer, it may be worth mentioning that Agrest framework (ex. LinkRest) supports rule-based serialization of Cayenne object graphs to JSON. But it is not a standalone component. I.e. it will only work if you use it for your REST services.