1

I'm able to successfully generate JSON file from Maximo however I would like to modify the JSON before it gets generated. Like below is the sample JSON that gets generated in Maximo,

{"lastreadingdate":"2020-01-30T16:48:33+01:00",
"linearassetmeterid":0,
"sinceinstall":0.0,
"lastreading":"1,150",
"plustinitrdng":0.0,
"sincelastinspect":0.0,
"_rowstamp":"568349195",
"assetnum":"RS100003",  
"active":true,  
"assetmeterid":85,
"lifetodate":0.0,
"measureunitid":"KWH",
"metername":"1010", 
"remarks":"TESTING JSON"}

I need the JSON to be generated as below ,

{"spi:action": "OSLC draft",
"spi:tri1readingdate":"2020-01-30T16:48:33+01:00",
"spi:tryassetmeterid":0,
"spi:install":0.0,
"spi:lastreadingTx":"1,150",
"spi:intrdngtrX":0.0,
and so on...}

Basically I need to change the target attribute names and prefix "spi" Below is the error occuring in JSON Mapping .

JSON mapping error

max092012
  • 365
  • 1
  • 5
  • 25
  • I don't have the ability to type up a proper answer right now, so I'll just quickly toss out there to look into the "JSON Mapping" application in the Integration module (near the bottom of that module's app list). – Dex Jan 31 '20 at 13:44

1 Answers1

2

You're not specifying how you generate the JSON file but I'll quickly explain how you can achieve this:

As Dex pointed out, there is a JSON Mapping app in the integration module that you can use to map your outbound object structure's fields to your target structure naming.

You define your JSON structure on the JSON Mapping tab by providing a JSON sample.

You then define your mapping with Maximo on the Properties tab, like this:

Example

Reading this IBM doc before jumping right into it should help you a lot: https://www.ibm.com/developerworks/community/wikis/form/anonymous/api/wiki/02db2a84-fc66-4667-b760-54e495526ec1/page/e10f6e96-435d-433c-8259-5690eb756779/attachment/169224c7-10a5-4cee-af72-697a476f8b2e/media/JSON

JPTremblay
  • 900
  • 5
  • 8
  • I'm generating the JSON file using the option "Publish JSON" that's present in the publish channel application in Maximo 7.6.1 . This does generate the JSON successfully however when I try to use JSON mapping and enter the Target property as you have mentioned in your screen shot it gives me the following error BMXAA4187E - The relationship spi:lastreadingTX does not exist for business object spi:lastreadingTX. Verify that the relationship specified in parameter spi:lastreadingTX exists in the Maxrelationship table. If I remove "spi" then it works without any issue – max092012 Jan 31 '20 at 15:49
  • You need to set your target JSON data structure in the multiline control on the JSON Mapping first. Maximo will parse it and in fact you should be able to select the parsed fields in the lookups on the Properties tab. I'll add those precisions to the answer. – JPTremblay Jan 31 '20 at 15:56
  • I'm getting the same error , I have added the screen shot in my question. – max092012 Jan 31 '20 at 16:37
  • 1. Create a mapping and associate it with the object structure of your Pub Channel 2. Copy your full target JSON data sample into JSON data multiline box 3. From the properties tab, map your OS objects/attributes to your JSON structure – JPTremblay Jan 31 '20 at 16:52
  • I did the same steps as you have stated, create PC and then map the same OS to the JSON mapping. The JSON gets generated without any issues if I do not use "spi:". The issue occurs only when I want spi: mapped before all the target attribute. I assume that JSON mapping does not support the ":" – max092012 Jan 31 '20 at 17:03
  • Yeah, it looks like the JSON Analyzer doesn't like your `spi:` prefix. I guess you could add that prefix back later in the integration process if you really need it, as a workaround... I'd suggest to notify IBM about this. – JPTremblay Jan 31 '20 at 22:45
  • As a note, that "spi:" prefix is a namespace and that needs to be defined on one of your elements at some level. If I get time this weekend (unlikely), I'll pull up my usage of it for reference and try to help out. I also remember you have to select a direction in your JSON mapping (whether this is outbound or inbound), which hasn't been mentioned yet (but that I assume you did). – Dex Jan 31 '20 at 23:23
  • @Dex Yes I have mentioned outbound in JSON mapping. I need this namespace to be defined at some level however I'm unable to figure out where should I do it. – max092012 Feb 01 '20 at 10:47
  • It turns out I did not deal with namespaces in my outbound JSON like I had thought, so I don't have specific help on that. I'm sorry. However, looking at your error message more, it is confusing to me that it is trying to find your whole field name in the relationship table. I would think it would not be doing that for _outbound_ properties. Can you confirm you are filling in the correct section? Unfortunately that JSON Mapping app has multiple "Properties" tabs, but only one should be filled in, depending on which direction it is for. – Dex Feb 02 '20 at 17:16