Forum Discussion

nullman's avatar
nullman
Occasional Contributor
13 years ago

Valid JSON not converted to XML (4.5.1 and 4.5.2)

Hi,

I am curious as to why soapUI is not able to convert this (valid) JSON to XML. I have tried 4.5.2 and 4.5.1 (on Max OSX). I do have a very similar response, where people is not null, and soapUI is able to convert it to XML. I am unsure if the null has anything to do with it, but thought I'd mention I can get some of these responses to convert to XML. Thanks for any assistance!


{
"res": {
"roleIds": [
"51bf53a85894585313fcc8c9",
"51bf53a85894585313fcc8cb"
],
"X-TESTING-Auth-Key": "6uxtwWk7a4Ct2xfV7w7JO5",
"app": {
"name": "TESTAPP",
"person": {
"fieldPaths": [
"general.name",
"general.title",
"general.department",
"status.status",
"primaryContactInfo.email",
"primaryContactInfo.voice",
"primaryContactInfo.sms",
"images.profile",
"images.informal",
"uploads.images",
"relationships.manager",
"relationships.administrativeAssistant",
"relationships.relationships",
"relationships.directReportCount",
"contactInfo.email_main",
"contactInfo.email",
"contactInfo.phone_work",
"contactInfo.phone_cell",
"contactInfo.phone_home",
"contactInfo.phone_other",
"contactInfo.im",
"contactInfo.address",
"location.location",
"skills.skills",
"skills.certs",
"education.education",
"bio.bio",
"bio.socialMedia",
"bio.workHistory",
"bio.interests",
"bio.hobbies",
"bio.spouse",
"bio.children",
"hr.officialName",
"hr.empId",
"hr.empType",
"hr.hireDate",
"hr.emergencyContactInfo"
],
"searchFieldPaths": [
"general.name",
"general.title",
"general.department",
"status.status",
"primaryContactInfo.email",
"primaryContactInfo.voice",
"primaryContactInfo.sms",
"images.profile",
"images.informal",
"uploads.images",
"relationships.manager",
"relationships.administrativeAssistant",
"relationships.relationships",
"relationships.directReportCount",
"contactInfo.email_main",
"contactInfo.email",
"contactInfo.phone_work",
"contactInfo.phone_cell",
"contactInfo.phone_home",
"contactInfo.phone_other",
"contactInfo.im",
"contactInfo.address",
"location.location",
"skills.skills",
"skills.certs",
"education.education",
"bio.bio",
"bio.socialMedia",
"bio.workHistory",
"bio.interests",
"bio.hobbies",
"bio.spouse",
"bio.children",
"hr.officialName",
"hr.empId",
"hr.empType",
"hr.hireDate",
"hr.emergencyContactInfo"
]
},
"mt": 1371493288,
"state": "active",
"version": 1,
"orgId": 1,
"_id": "51bf53a85894585313fcc8c8"
},
"user": {
"mt": 1371563393,
"apps": {"51bf53a85894585313fcc8c8": [
"51bf53a85894585313fcc8c9",
"51bf53a85894585313fcc8cb"
]},
"userType": "admin",
"state": "active",
"version": 3,
"lastLogin": 1371578055,
"_id": "51c06472a73aa71f9a2ddbe5",
"email": "admin@junk.com"
},
"person": null
},
"ms": 143
}

3 Replies

  • nullman's avatar
    nullman
    Occasional Contributor
    I think I've figured out what is happening in my OP and hopefully this will help others.

    SoapUI is trying to convert a key (apps) to an element name in XML, but the key starts with a number. This is valid JSON, but in XML an element name cannot start with number.

    If it isn't "too much trouble" development might preface it with a "_" (legal in XML). Otherwise I guess I'll be getting more familiar with Groovy to transfer property values.
  • I am also facing the similar issue on REST POST request. Using latest soapui 4.5.2.

    Valid Json
    {
    "user": {
    "userId": 12347664,
    "userName": "xxx@gmail.com",
    "emailAddress": "xxx@gmail.com",
    "firstName": "some",
    "lastName": "TEMP",
    "defaultProfileId": 873112
    },
    "account": {
    "type": "FREE",
    "features": []
    },
    "currentProfileId": 873112,
    "userProfiles": [
    {
    "profileId": 873112,
    "name": "Default Profile",
    "profileTypeId": 1
    }
    ],
    "parentProfiles": [
    {
    "profileId": 873112,
    "name": "Default Profile",
    "profileTypeId": 1
    }
    ]
    }


    json tab :
    <Not JSON content>


    XML tab shows:
    <data contentType="null" contentLength="383"><![CDATA[{"user":{"userId":12347664,"userName":"xxx@gmail.com","emailAddress":"xxx@gmail.com","firstName":"some","lastName":"TEMP","defaultProfileId":873112},"account":{"type":"FREE","features":[]},"currentProfileId":873112,"userProfiles":[{"profileId":873112,"name":"Default Profile","profileTypeId":1}],"parentProfiles":[{"profileId":873112,"name":"Default Profile","profileTypeId":1}]}]]></data>


    raw:
    HTTP/1.1 200 OK
    Date: Thu, 27 Jun 2013 12:47:21 GMT
    Server: Apache/2.4.3 (Unix) OpenSSL/1.0.0-fips mod_jk/1.2.37
    Set-Cookie: JSESSIONID=D0A0B36C6E071D5F1043E5DC4D7EC453.worker4; Path=/
    Set-Cookie: ORIGINAL_PATH=""; Domain=.domain.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
    Content-Length: 383
    Keep-Alive: timeout=5, max=100
    Connection: Keep-Alive

    {"user":{"userId":12347664,"userName":"xxx@gmail.com","emailAddress":"xxx@gmail.com","firstName":"some","lastName":"TEMP","defaultProfileId":873112},"account":{"type":"FREE","features":[]},"currentProfileId":873112,"userProfiles":[{"profileId":873112,"name":"Default Profile","profileTypeId":1}],"parentProfiles":[{"profileId":873112,"name":"Default Profile","profileTypeId":1}]}
  • MartinSpamer's avatar
    MartinSpamer
    Frequent Contributor
    The Response header must include a Content-Type.

    e.g.

    Content-Type: application/json;charset=utf-8