Generic JSON Inbound Adapter - Source Code Available? How about a Less Generic Version?

1132
2
02-01-2017 04:51 PM
MarkHolzworth
New Contributor II

We may have a need to augment the functionality of the provided Generic JSON Input Adapter.  Is the source code available (or would we need to start from scratch?   Does anybody know of a more full-featured JSON adapter?  How about a way to solve the problem below using an out-of-the box processor?

Why would we need to do this?   We are having difficulties mapping some of our input JSON which resides in an array where the property of interest is not necessarily at the same index, and rther requires the extraction of both the name and the value of the property from values in the array.

Example - We need to transform:

          "accumulators" : [ {
            "label" : "Odometer",
            "value" : "5200.54",
            "units" : "mi",
          }, {
            ...
          }, {
            ...
          } ]
 
… to this:
 
          "Odometer" : {
            "value" : "5200.54",
            "units" : "mi",
            "type" : "Distance"
          },
            ...
          },
            ...
          }

Thank You,

Mark

0 Kudos
2 Replies
BrianLomas
Occasional Contributor III

Has anyone figured out a solution for this? I'm having a similar problem. I am using the MQTT transport connector but my data flow is not correct. Below is an example of the incoming json. The issue is the dynamic timestamp at the beginning. I am thinking an adapter could fix the issue but I'm not sure how to go about creating it. Anyone have an idea?

{
"1522690612002": {
"atp.wtx": 125735,
"atp.link": "cell1"
},
"1522690615002": {
"atp.glat": 52.2458673,
"atp.ghed": 0,
"atp.glon": -96.4189001,
"atp.gspd": 0
}
}

0 Kudos
BrianLomas
Occasional Contributor III

FYI: We ended up developing a python script that would read the json from the MQTT broker then parse the data and reconstruct it into a format that worked for us. Then, we simply sent it back to the broker with a new topic name. This has worked pretty well so far and with virtually no latency.