fasterxml jackson JSON deserialization - custom adding - jackson

I use Jackson FasterXML product to deserialize JSONs. Now, I noticed in profiler that I got a ton of duplicate strings as a result since every time I receive a JSON it deserialize into an object which always contains some String variable which tells me the Type name. (it's answer to Facebook GraphQL query). Now, naturally, I would prefer for .intern() method to be used during deserialization of this specific method. Is that possible? If so, how?

Seems StringDeserializer can provide whttp://stackoverflow.com/questions/17041249/jackson-override-primitive-type-deserialization

Related

Why do we need to use POJO class and serialization in RestAssured, when we can directly send request body in the form of String?

What is the realtime use case for serialization in RestAssured?
Even though we can send request body(JSON) as String.
I tried googling but did not get satisfying results.
There are few advantages that come up as your code logic becames more complicated:
You might want to send the same object to different endpoint which might not support json but xml content type. So you can simply have one pojo and RestAssured would take care of all conversions.
Your object might change in runtime. So you will have to introduce changes to your string accordingly. This is quite an error-prone way. Serializer would assure that you send somewhat what is a proper json considering syntax stuff, escaping what needs to be escaped and so on.
There might be the case when you fetch object from one endpoint and send it to another. Hence you would be able to use class for deserialization and further serialization in runtime.

SpringFox/Jackson doesn't parse JSON attribute

I'm using Spring boot with springfox and having problems parsing JSON payload from Swagger UI into Java class (JSON->POJO). No errors, but the resulting Java object is missing a field (null). The top class for the class with missing attribute has Mixin to switch datatypes. That part works fine.
I can't really debug since framework does most of the parsing. The req-d attribute is displayed in Swagger under Model Schema correctly. However, when I submit JSON payload containing same attribute, the corresp POJO's attribute is null.
Please steer me to the right direction.
I've figured it out my issue: I was missing setter for the field in the Mixin interface. The JSON was being parsed, but the setter was missing, hence null value.

RestKit Serialization of related entities

I'm trying to send a POST request with RestKit. I have an entity (called workout) that I want to serialize and send to my server backend.
The workout Entity has-one related Entity (called exercise) which has a name.
The Problem I have is that my server expects the JSON in a little bit different format than what RestKit sends:
What the backend receives is the following: exercise[name]. Note that the name attribute of the related entity exercise is in square brackets.
My Server expects these attributes in the following form: exercise.name.
My question is: How can I tell RestKit to use a dot instead of square brackets when serializing entities?
I've looked into setSourceToDestinationKeyTransformationBlock but I could'nt figure out how to use it to solve my problem.
By default RestKit will use form URL encoded serialisation (and that's what it looks like you're getting). To correct this, set the serialisation type to JSON:
objectManager.requestSerializationMIMEType = RKMIMETypeJSON;

How do I add a SOAP template from XSD in soapUI when XML extension is in place?

I need to make a large number of SOAP test cases to automate the testing process of an application.
Currently, the architecture requires that a single "generic" SOAP method is invoked with an object of a generic type. Each "real" operation is defined by an element in the generic object and requires an object of an extended type to be used as input.
When I create the request template with soapUI, I only get the generic object elements, but I would like to add the empty template for a specific XSD type that is defined in my current schema to be used.
If I use xsi:type then soapUI correctly says that my markup is not valid against the schema (missing required elements), but I can't manage to get a ready-to-fill XML template.
Can you help me?
Example
genericRequest is made of
<genericRequest>
<methodName>specificMethodName</methodName>
<authenticationID>ABCDEF</authenticationID>
</genericRequest>
sumReuqest (extending genericRequest) for a "sum" operation is made of
<sumRequest>
<methodName>specificMethodName</methodName>
<authenticationID>ABCDEF</authenticationID>
<addend>5</addend>
<addend>3</addend>
</sumRequest>
I would ultimately like soapUI to fill a SOAP template with empty addend item (of course I work with lots of elements, and they are structured too!!)
In this case you need to create two resources in soaupUI one for generic request and other for operation request, I know right now its pain to create each resource for each operation, but soapUI is developed like that or if you think any of the parameters listed : http://www.soapui.org/REST-Testing/understanding-rest-parameters.html could help, you could define parameters as one of the above.
you could try using QUERY or MATRIX style parameters in your resource.

How to get the value from MessageHeaderInfo

I am sending some SOAP headers to a WCF service and I am trying to catch them using behavior extension.
When the message is received I am going through its headers collection.
Each header is of MessageHeaderInfo type which does not have a value property.
How can I extract the value? It can be done with an ugly parsing (to remove the xml elements around the value) but it feels lame.
your help is most appriciated!
The way you normally use message headers is by defining a DataContract (or an XmlSerializable class) to represent your header, then use Message.Headers.GetHeader<T>() to retrieve it. That method will do the deserialization and hand you a strongly typed object you can use.