|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Convert JSON to Java Object |
« View previous topic :: View next topic » |
Author |
Message
|
wmqstankela |
Posted: Wed Jan 23, 2019 6:55 am Post subject: Convert JSON to Java Object |
|
|
Voyager
Joined: 29 Feb 2016 Posts: 94
|
Hi all,
I have REST service with JSON as input message. I want in JCN to convert that input JSON message into Java object, something like JAXB for XML messages.
Let's say that my input message looks like this:
Code: |
{
"request": {
"id": 123,
"name": "John",
"mail": "john@example.com"
}
} |
and I have class Request that has fields id,name and mail. Is it possible to convert(unmarshal) this JSON to java object Request? Can someone help me how to do this? |
|
Back to top |
|
 |
timber |
Posted: Thu Jan 24, 2019 4:22 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
This is not really an IIB question - it's a Java programming question.
Most people on this forum will advise you to
-use the JSON parser that comes with IIB
- process the message tree using ESQL or the Mapping node.
Do you have a special reason for wanting to create a Java object? |
|
Back to top |
|
 |
martinevans |
Posted: Fri Jan 25, 2019 2:54 am Post subject: |
|
|
 Newbie
Joined: 25 Feb 2008 Posts: 4
|
You could pass your JSON message into a JCN, instantiate your "Request" class, set the fields using the data from the input message and then serialise the object and pass it along as a BLOB to whatever node will send it to the Java program that will deserialise it. This assumes your class has implemented Serializable. |
|
Back to top |
|
 |
wmqstankela |
Posted: Mon Jan 28, 2019 5:26 am Post subject: |
|
|
Voyager
Joined: 29 Feb 2016 Posts: 94
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|