Author |
Message
|
issac |
Posted: Sat May 21, 2011 12:14 am Post subject: How to save Json message into database? |
|
|
 Disciple
Joined: 02 Oct 2008 Posts: 158 Location: Shanghai
|
Hello,
HELP says Json Parser uses ASBITSTREAM for serialization too. However, I tried this and it's not working:
DECLARE taskValue CHARACTER InputRoot.JSON.Data.task;
DECLARE dataValue BLOB ASBITSTREAM(InputRoot.JSON.Data, InputRoot.properties.Encoding, InputRoot.properties.CodedCharSetId);
INSERT INTO Database.ISSAC.REQUEST_HISTORY(TASK, DATA, TIME, REQUEST_ID)
VALUES(taskValue, dataValue, 'qq', 'jj');
--------------------------
My message is:
{
"task":"list",
"data":
{
"checkedEventType":"GLOBAL",
"target":[
{"eventType":"#CALL",
"status":"-OPEN ",
"maxResult":10},
{
"eventType":"#TODO",
"status":"-OPEN ",
"maxResult":10}
]
}
}
As I trace the flow, InputRoot.JSON.Data.data is correctly parsed. But the variable dataValue is NULL. _________________ Bazinga! |
|
Back to top |
|
 |
issac |
Posted: Sat May 21, 2011 3:23 pm Post subject: |
|
|
 Disciple
Joined: 02 Oct 2008 Posts: 158 Location: Shanghai
|
any idea? please, thanks in advance. _________________ Bazinga! |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat May 21, 2011 5:29 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
I thought ASBITSTREAM required an options parameter. I did not see you passing one.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
issac |
Posted: Sat May 21, 2011 7:07 pm Post subject: |
|
|
 Disciple
Joined: 02 Oct 2008 Posts: 158 Location: Shanghai
|
I remember that option too. But the statement is copied from Broker HELP for XMLNSC Parser.
Whatsoever I've dropped the idea to use Json parser. Lack of examples is one of the reasons. But the most important thing is that I've confirmed WMB does not support message modeling and validation for the Json Domain. I went for JSONML to convert Json into XML. _________________ Bazinga! |
|
Back to top |
|
 |
rekarm01 |
Posted: Sun May 22, 2011 3:03 am Post subject: Re: How to save Json message into database? |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
issac wrote: |
Code: |
DECLARE dataValue BLOB ASBITSTREAM(InputRoot.JSON.Data, InputRoot.properties.Encoding, InputRoot.properties.CodedCharSetId); |
|
"InputRoot.properties" is misspelled. The ENCODING and CCSID parameters are likely NULL. The JSON parser does not use the ENCODING parameter.
issac wrote: |
As I trace the flow, InputRoot.JSON.Data.data is correctly parsed. But the variable dataValue is NULL. |
If any ASBITSTREAM parameter is NULL, then the result is NULL.
fjb_saper wrote: |
I thought ASBITSTREAM required an OPTIONS parameter. |
It does not. The default value for the OPTIONS parameter is (RootBitStream & ValidateNone), in which case, the given field reference (InputRoot.JSON.Data) is also wrong. |
|
Back to top |
|
 |
issac |
Posted: Sun May 22, 2011 5:35 pm Post subject: |
|
|
 Disciple
Joined: 02 Oct 2008 Posts: 158 Location: Shanghai
|
Hi! Thanks for the support.
I'll try specifying exact numbers as CCSID and encoding. _________________ Bazinga! |
|
Back to top |
|
 |
fjb_saper |
Posted: Sun May 22, 2011 9:35 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
issac wrote: |
Hi! Thanks for the support.
I'll try specifying exact numbers as CCSID and encoding. |
It's not about the exact number, what rekarm01 tried to tell you is that you need to spell properties in InputRoot.Properties with a capital 'P', and yes case does matter.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Mon May 23, 2011 3:22 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
issac wrote: |
Hi! Thanks for the support.
I'll try specifying exact numbers as CCSID and encoding. |
It's not about the exact number, what rekarm01 tried to tell you is that you need to spell properties in InputRoot.Properties with a capital 'P', and yes case does matter.  |
He's also saying that you can't use the default options to serialize part of a message tree. You need to specify FolderBitStream to serialize part of a message tree, rather than RootBitStream.
And I've not double-checked whether the JSON parser supports FolderBitStream either - it might or might not. |
|
Back to top |
|
 |
dilse |
Posted: Mon May 23, 2011 5:53 am Post subject: |
|
|
 Master
Joined: 24 Jun 2004 Posts: 270
|
One other thing I noticed above is that you are trying to ASBITSTREAM "InputRoot.JSON.Data" but the actual field you mentioned being "InputRoot.JSON.Data.data". _________________ DilSe..
Take life as it comes.. |
|
Back to top |
|
 |
namarn |
Posted: Tue May 08, 2012 4:36 am Post subject: |
|
|
Newbie
Joined: 08 May 2012 Posts: 1
|
I also have similar requirement. I need to convert the JSON tree to a string. Is there a solution this? |
|
Back to top |
|
 |
mqjeff |
Posted: Tue May 08, 2012 4:44 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
namarn wrote: |
I also have similar requirement. I need to convert the JSON tree to a string. Is there a solution this? |
Yes.
Use the proper options to ASBITSTREAM.
Or use an *Output node to serialize the logical message tree into a bitstream in some connectivity container (a message, a file, a tcp/ip stream, etc) |
|
Back to top |
|
 |
lancelotlinc |
Posted: Tue May 08, 2012 5:02 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
mqjeff wrote: |
namarn wrote: |
I also have similar requirement. I need to convert the JSON tree to a string. Is there a solution this? |
Yes.
Use the proper options to ASBITSTREAM.
Or use an *Output node to serialize the logical message tree into a bitstream in some connectivity container (a message, a file, a tcp/ip stream, etc) |
One option you may like to Google is called 'RootBitStream'. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
|