cancel
Showing results for 
Search instead for 
Did you mean: 

How to do a XML to JSON mapping

0 Kudos
482

I am trying to post the User's bulk data into IAS system. limitations is that IAS system accepts data only in JSON format. I am trying to map the following XML to JSON in CPI message mapping. Following is my source structure.

<Employees>
  <Employee>
    <displayName>John Smith</displayName>
    <firstName>John</firstName>
    <lastName>Smith</lastName>
    <managerName>abc def</managerName>
    <managerEmail>abc@gmail.com</managerEmail>
    <managerSCIMID>f7acd9a7-03c5-4a94-a432-5ae5e0b3068b</managerSCIMID>
    <mobilePhone>+91 1234567890</mobilePhone>
    <email>john.smith@example.com</email>
    <SAMAccountName>john.smith@example.com</SAMAccountName>
    <userPrincipalName>johnsmith</userPrincipalName>
  </Employee>
  <Employee>
    <displayName>George Adams</displayName>
    <firstName>George</firstName>
    <lastName>Adams</lastName>
    <managerName>pqr uvw</managerName>
    <managerEmail>pqr@gmail.com</managerEmail>
    <managerSCIMID>3f5fe8f9-1e4a-4253-ae1e-b096272e7d2b</managerSCIMID>
    <mobilePhone>+91 2345678901</mobilePhone>
    <email>georgeadams@example.com</email>
    <SAMAccountName>georgeadams@example.com</SAMAccountName>
    <userPrincipalName>georgeadams</userPrincipalName>
  </Employee>
  <Employee>
    <displayName>Jessica Grey</displayName>
    <firstName>Jessica</firstName>
    <lastName>Grey</lastName>
    <managerName>pqr uvw</managerName>
    <managerEmail>pqr@gmail.com</managerEmail>
    <managerSCIMID>f7acd9a7-03c5-4a94-a432-5ae5e0b3068b</managerSCIMID>
    <mobilePhone>+91 3456789012</mobilePhone>
    <email>jessicagrey@example.com</email>
    <SAMAccountName>jessicagrey@example.com</SAMAccountName>
    <userPrincipalName>jessicagrey</userPrincipalName>
  </Employee>
</Employees>

My target structure looks as:

{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:BulkRequest"
    ],
    "Operations": [
        {
            "method": "POST",
            "bulkId": "4ecf320f-7bfe-4f8b-91dc-f8f52322d713",
            "path": "/Users",
            "data": {
                "schemas": [
                    "urn:ietf:params:scim:schemas:core:2.0:User",
					"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
                ],
                "userName": "johnsmith",
                "name": {
                    "familyName": "Smith",
                    "givenName": "John"
                },
                "displayName": "John Smith",
                "active": true,
                "emails": [
                    {
                        "value": "john.smith@example.com",
                        "primary": true,
                        "type": "home"
                    }
                ],
				"phoneNumbers": [
                    {
                        "value": "333-333-3333",
                        "primary": true,
                        "type": "work"
                    }
                ],
				"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                    "manager": {
                        "value": "f7acd9a7-03c5-4a94-a432-5ae5e0b3068b"
                    }
                }
            }
        },
        {
            "method": "POST",
            "bulkId": "11020828-2bc8-45c4-876b-e32b6259fafc",
            "path": "/Users",
            "data": {
                "schemas": [
                    "urn:ietf:params:scim:schemas:core:2.0:User",
                    "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
                ],
                "userName": "georgeadams",
                "name": {
                    "familyName": "Adams",
                    "givenName": "George"
                },
                "displayName": "George Adams",
                "active": true,
                "emails": [
                    {
                        "value": "georgeadams@example.com",
                        "primary": true,
                        "type": "home"
                    }
                ],
				"phoneNumbers": [
                    {
                        "value": "444-444-4444",
                        "primary": true,
                        "type": "work"
                    }
                ],
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                    "manager": {
                        "value": "f7acd9a7-03c5-4a94-a432-5ae5e0b3068b"
                    }
                }
            }
        },
        {
            "method": "POST",
            "bulkId": "52b3e095-62c2-4baf-8c0f-106a555537ff",
            "path": "/Users",
            "data": {
                "schemas": [
                    "urn:ietf:params:scim:schemas:core:2.0:User",
                    "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
                ],
                "userName": "jessicagrey",
                "name": {
                    "familyName": "Grey",
                    "givenName": "Jessica"
                },
                "displayName": "Jessica Grey",
                "active": true,
                "emails": [
                    {
                        "value": "jessicagrey@example.com",
                        "primary": true,
                        "type": "home"
                    }
                ],
				"phoneNumbers": [
                    {
                        "value": "555-555-5555",
                        "primary": true,
                        "type": "work"
                    }
                ],
                "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
                    "manager": {
                        "value": "f7acd9a7-03c5-4a94-a432-5ae5e0b3068b"
                    }
                }
            }
        }
    ]
}

 I've tried the JSON mapping approach on the blog : blog for JSON mapping 

After uploading JSON file in message mapping from business accelerator hub: Business Accelerator hub it is showing no data.

omkarvilas_a_kandekar_0-1706625955827.png

 

Because of the schemas fields I can not perform XML to XML mapping.

What should I do for XML to JSON conversion?

Accepted Solutions (0)

Answers (0)