jsonStringToDocument mapping to a custom Document

Hello Everyone,

I am using webMethods version 9.12

There is a REST API which i am using to fetch data from some external system. I need to insert this data into my database system. When i fetch the data through API and convert the API response using Standard jsonStringToDocument service , i get a document file as response having json data inside it. Now in order to insert this data into database i need to map this into a Document/document list so that i can map this to any insertadapterservice. This is the part where i am facing the issue, because json format inside the document is complex and i am not able to make a custom document matching the format of json below.

{
    "attributes": {
        "type": "ContactPointTypeConsent",
        "url": "/services/data/v62.0"
    },
    "Id": "0ZYBi0000000AszOAE",
    "Name": "ANA",
    "Party": {
        "attributes": {
            "type": "Individual",
            "url": "/services/data/v62.0/"
        },
        "Account__c": "001Bi00000MeqRhIAJ"
    },
    "DataUsePurpose": {
        "attributes": {
            "type": "DataUsePurpose",
            "url": "/services/data/v62.0/"
        },
        "Name": "General"
    },
    "EffectiveFrom": 1749780560000,
    "ContactPointType": null,
    "PrivacyConsentStatus": "OptIn",
    "CaptureContactPointType": null,
    "EAI_UP_DT__c": null
}

can anyone suggest any way to map this output to a custom document or document list, so that individual values can be used further in the mapping. The actual document has a set of such records.
or
If there is an alternate way of achieving the same.

Thank you for the assistance

FYI,
image
Banner is above the website.

To your question, the JSON structure didn’t look complicated to me. I don’t see your insert adapter service, so its not clear what your target document supposed to look like. When I need to consume a JSON API, I usually create a JSON document from the sample response and pass that response document as output document, you can do the same for input document as well.


The benefit of passing document as input/output is you don’t need to manually convert json strings to documents and vice versa. Another benefit is you can have a webservice that returns any format the consumer wants. This service wraps the http client service in your case.

By the look of it (just an assumption since I don’t know what you are struggling with) the only place you can struggle seems to be the attributes complex type. If you are trying to map these generic properties to predefined columns, you may need to do it hard coded since there is no way of knowing what the attribute type you are going to receive.

If you already know what you are expecting and only interested in some of these fields, may be the service below will help you.
pub.document:documentListToDocument
I don’t remember if this service existed back in version 9.12. 9.12 is extremely old version IMO, there were 2 major versions(10 and 11) released after that version. It is a security vulnerability and you are missing a lot of the new functionalities. I suggest upgrading the environment ASAP.

Thank you for the response.
Actually the complete json looked like this.

[
{
“attributes”: {
“type”: “ContactPointTypeConsent”,
“url”: “/services/data/v62.0/”
},
“Id”: “0ZYBi0000000AszOAE”,
“Name”: “ANA R MONEYGANDAN_General_2025-06-13 02:09:20”,
“Party”: {
“attributes”: {
“type”: “Individual”,
“url”: “/services/data/v62.0/”
},
“Account__c”: “001Bi00000MeqRhIAJ”
},
“DataUsePurpose”: {
“attributes”: {
“type”: “DataUsePurpose”,
“url”: “/services/data/v62.0/”
},
“Name”: “General”
},
“EffectiveFrom”: 1749780560000,
“ContactPointType”: null,
“PrivacyConsentStatus”: “OptIn”,
“CaptureContactPointType”: null,
“EAI_UP_DT__c”: null
},
{
“attributes”: {
“type”: “ContactPointTypeConsent”,
“url”: “/services/data/v62.0/sobjects/ContactPointTypeConsent/0ZYBi0000000At0OAE”
},
“Id”: “0ZYBi0000000At0OAE”,
“Name”: “ANA R MONEYGANDAN_Marketing_2025-06-13 02:09:20”,
“Party”: {
“attributes”: {
“type”: “Individual”,
“url”: “/services/data/v62.0/sobjects/Individual/0PKBi0000000dXtOAI”
},
“Account__c”: “001Bi00000MeqRhIAJ”
},
“DataUsePurpose”: {
“attributes”: {
“type”: “DataUsePurpose”,
“url”: “/services/data/v62.0/sobjects/”
},
“Name”: “Marketing”
},
“EffectiveFrom”: 1749780560000,
“ContactPointType”: null,
“PrivacyConsentStatus”: “OptIn”,
“CaptureContactPointType”: null,
“EAI_UP_DT__c”: null
},
{
“attributes”: {
“type”: “ContactPointTypeConsent”,
“url”: “/services/data/v62.0/sobjects/”
},
“Id”: “0ZYBi0000000At1OAE”,
“Name”: “ANA R MONEYGANDAN_Survey_2025-06-13 02:09:20”,
“Party”: {
“attributes”: {
“type”: “Individual”,
“url”: “/services/data/v62.0/sobjects/”
},
“Account__c”: “001Bi00000MeqRhIAJ”
},
“DataUsePurpose”: {
“attributes”: {
“type”: “DataUsePurpose”,
“url”: “/services/data/v62.0/sobjects/”
},
“Name”: “Survey”
},
“EffectiveFrom”: 1749780560000,
“ContactPointType”: null,
“PrivacyConsentStatus”: “OptOut”,
“CaptureContactPointType”: null,
“EAI_UP_DT__c”: null
}
]

when i convert this using jsonStringtToDocument, i was having trouble making the document list that could take all these records. I have already created a custom doc by copying the output structure for jsonStringToDocument output which looked like this but was not getting the structure right for this.

I think the problem was while creating custom doc i was renaming the $rootArray variable to something else, i think that’s why it was not mapping result to the custom doc earlier.

It is working now. Thanks for the support.

Yeah, we are planning for a version update in the near future. This version does have many key functionalities missing.