AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Info on handling json in oob data
 
 

when I pass in this oob data

[{"channelData":{"eventName":"ready""eventDataInfo":{location:{"path":"web/sales/medicare"}}}}] qwerty 

and then call ^jsonParse() followed by ^jsontree() I get

{    # jo-t0
  
"channelData"{    # jo-t1000
    
"eventName""ready",
    
"_"eventDataInfo""{    # jo-t1001
      
"location"{    # jo-t1002
        
"path""web/sales/medicare"
      
}
    }
  }

what I don’t understand is why eventDataInfo looks like it does.

It makes it where channelData.eventDataInfo not work.

I put in some extra logging in the controller like this.

topic: ~swgcontrol system ()
u
START_SENTENCE_PROCESSING ()
 ^
log(\n\n *** start processing sentence: %originalsentence *** \n)

# allow for json formatted oobData, including channelData that will be sent back to 
# the calling channel adapter.
 
uPARSE_OOB_DATA (\[ _* ) 
 ^
logthis is the raw oob data_0)
 $
$oobInData = ^jsonparsetransient NOFAIL _0
 ^
log\n oobInData: ^jsontree($$oobInData) ) 

and I see:

*** start processing sentence[ {"channelData":{"eventName":"ready""eventDataInfo":{location:{"path":"web/sales/medicare"}}}} ] ***
this is the raw oob data{"channelData":{"eventName":"ready",_"eventDataInfo":{location:{"path":"web/sales/medicare"}}}} ]
incoming channelData
JSON=> 
{    # jo-t1000
  
"eventName""ready",
  
"_"eventDataInfo""{    # jo-t1001
    
"location"{    # jo-t1002
      
"path""web/sales/medicare"
    
}
  }
}
<=JSON 

it seems that the space between the commma after “ready” and before “eventDataInfo” is causeing an underbar to be inserted which in turn is messing up the ^jsonparse()


If I remove the space then I get

*** start processing sentence[ {"channelData":{"eventName":"ready","eventDataInfo":{location:{"path":"web/sales/medicare"}}}} ] ***
this is the raw oob data{"channelData":{"eventName":"ready","eventDataInfo":{location:{"path":"web/sales/medicare"}}}} ]
incoming channelData
JSON=> 
{    # jo-t1000
  
"eventName""ready",
  
"eventDataInfo"{    # jo-t1001
    
"location"{    # jo-t1002
      
"path""web/sales/medicare"
    
}
  }
}
<=JSON 

and $$oobindata.channelData.eventDataInfo.location.path works just fine!

Conclusion and Note to All

I think the lesson learned is that if you are capturing OOB data via a pattern match, the pattern matcher will insert underbars between json tokens.

 

 

 
  [ # 1 ]

I will check into why this happens for you, BUT…. you should not really call JSON parse on this data.
What you should do is pass in JSON as OOB wrapped JSON, meaning whatever json you want, put the [ ] of oob around it, and request on your CS_token variable to have the system auto parse it for you and return the json object

 

 
  [ # 2 ]

and it would help if there were spaces among your tokens.

 

 
  [ # 3 ]

This post was helpful to me as well.

 

 
  [ # 4 ]

There is a working example in ChatScript-Exotica-Examples in the section, Passing in parameters.

 

 
  login or register to react