ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportConvert JSON to Java Object

Post new topicReply to topic
Convert JSON to Java Object View previous topic :: View next topic
Author Message
wmqstankela
PostPosted: Wed Jan 23, 2019 6:55 am Post subject: Convert JSON to Java Object Reply with quote

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
View user's profile Send private message
timber
PostPosted: Thu Jan 24, 2019 4:22 am Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1011

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
View user's profile Send private message
martinevans
PostPosted: Fri Jan 25, 2019 2:54 am Post subject: Reply with quote

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
View user's profile Send private message
wmqstankela
PostPosted: Mon Jan 28, 2019 5:26 am Post subject: Reply with quote

Voyager

Joined: 29 Feb 2016
Posts: 94

Thanks
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportConvert JSON to Java Object
Jump to:



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
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.