Hi all,

I am trying to enrich a JSON record payload with some extra JSON stored on a 
Redis server by doing a LookupRecord, backed up with a 
DistibutedMapCacheLookupService, RedisDistributionMapCacheClientService and a 
RedisConnectionPoolService.

The JSON is stored as a string which I load into the data base with the pipe 
protocol, like this.

*3
$3
SET
$10
protocol.6
$79
{"name":"tcp","code":6,"alias":"TCP","comment":"transmission control protocol"}

And from the command line it looks like this.

get protocol.6
"{\"name\":\"tcp\",\"code\":6,\"alias\":\"TCP\",\"comment\":\"transmission 
control protocol\"}"

So already I am a bit on edge as this is getting escaped. I configure the 
lookup with the following parameters.


  *   Result RecordPath = /Enrichment/Network/Transport
  *   Routing Strategy = Route To Success
  *   Record Result Contents = Insert Entire Record
  *   Record Update Strategy = Use Property
  *   key = concat('protocol.',/network/iana_number)
Where each input record includes an integer already in the field 
"/network/iana_number".

The first thing I notice is that if the path "/Enrichment/Network/Transport" 
does not already exist in the record then the result will not create the right 
path, but instead my result will get put somewhere like 
"/Enrichment/Transport". So further upstream I have to include the creation of 
that path in a Jolt transform.

The second thing is that the return value is a String, not JSON, and looks like 
this.

"Enrichment" : {
  "Network" : {
    "Transport" : 
"{\"name\":\"tcp\",\"code\":6,\"alias\":\"TCP\",\"comment\":\"transmission 
control protocol\"}"
  }
}

So I have the escaped string still, not the JSON record I was hoping for. I can 
try an UpdateRecord with this transformation:

/Enrichment/Network/transport = unescapeJson(/Enrichment/Network/Transport)

and look at the results side by side.

"Enrichment" : {
  "Network" : {
    "Transport" : 
"{\"name\":\"tcp\",\"code\":6,\"alias\":\"TCP\",\"comment\":\"transmission 
control protocol\"}",
    "transport" : "{name=tcp, code=6, alias=TCP, comment=transmission control 
protocol}"
  }
}

So it is still a string, and not a record. I have a feeling I lost battle at 
the Redis storage side; once the server was adamant it was a String there was 
nothing else I could do, but I was wondering what else I could try. I have 
tried various ways to remove the escaping but none resolve my issue. I was 
wondering if anybody else had seen this sort of problem and had resolved it 
successfully.

I could probably move forward with some regexes but that seems to contradict 
the point of passing JSON around in the first place.

Thanks in advance.

Steve Hindmarch

Reply via email to