So I am working with the D&B Hoover Direct 2.0 API to try and integrate data from there to Salesforce. I am successfully getting a JSON response that looks as follows:
{
"FindCompanyResponse": {
"@ServiceVersionNumber": "6.0",
"TransactionDetail": {
"ApplicationTransactionID": "EntyLstFindCmpny23JAN01",
"ServiceTransactionID": "Id-bce2b7e552e5f07e183b742e-1",
"TransactionTimestamp": "2014-01-27T00:37:08"
},
"TransactionResult": {
"SeverityText": "Information",
"ResultID": "CM000",
"ResultText": "Success"
},
"FindCompanyResponseDetail": {
"CandidateMatchedQuantity": 9753837,
"CandidateReturnedQuantity": 2,
"FindCandidate": [
{
"DUNSNumber": "379200822",
"OrganizationPrimaryName": {
"OrganizationName": {
"$": "ELECTRICITAT JORDI, S.L."
}
},
"MarketabilityIndicator": true,
"PrimaryAddress": {
"StreetAddressLine": [
{
"LineText": "Edificio Font"
},
{
"LineText": "Local 2 Pb 1"
}
],
"PrimaryTownName": "Andorra La Vella",
"CountryISOAlpha2Code": "AD",
"PostalCode": "AD500 AD500"
},
"TelephoneNumber": {
"TelecommunicationNumber": "805850"
},
"FacsimileNumber": {
"TelecommunicationNumber": "805854"
},
"StandaloneOrganizationIndicator": true,
"IndustryCode": [
{
"@DNBCodeValue": 3599,
"@TypeText": "D&B Standard Industry Code",
"IndustryCode": {
"$": "17310000"
},
"IndustryCodeDescription": [
{
"@IndustryCodeDescriptionLengthCode": 2121,
"$": "ELECTRICAL WORK"
}
]
}
],
"ConsolidatedEmployeeDetails": {
"TotalEmployeeQuantity": 6
},
"PubliclyTradedCompanyIndicator": false,
"UpwardFamilyMemberPubliclyTradedCompanyIndicator": false,
"SalesRevenueAmount": {
"@CurrencyISOAlpha3Code": "USD",
"@UnitOfSize": "Million",
"$": 0.95148
},
"DisplaySequence": 1
},
{
"DUNSNumber": "464375850",
"OrganizationPrimaryName": {
"OrganizationName": {
"$": "ALEXANDRE SELECCIONS GASTRONOMIQUES SL"
}
},
"TradeStyleName": [
{
"OrganizationName": {
"$": "ASG"
}
}
],
"MarketabilityIndicator": true,
"PrimaryAddress": {
"StreetAddressLine": [
{
"LineText": "Ctra De La Comella 130 Edf Forn Elies"
}
],
"PrimaryTownName": "Andorra La Vella",
"CountryISOAlpha2Code": "AD",
"PostalCode": "AD500 AD500"
},
"TelephoneNumber": {
"TelecommunicationNumber": "864242"
},
"FacsimileNumber": {
"TelecommunicationNumber": "863438"
},
"StandaloneOrganizationIndicator": true,
"IndustryCode": [
{
"@DNBCodeValue": 3599,
"@TypeText": "D&B Standard Industry Code",
"IndustryCode": {
"$": "51490000"
},
"IndustryCodeDescription": [
{
"@IndustryCodeDescriptionLengthCode": 2121,
"$": "GROCERIES,REL PDS NEC"
}
]
}
],
"ConsolidatedEmployeeDetails": {
"TotalEmployeeQuantity": 5
},
"PubliclyTradedCompanyIndicator": false,
"UpwardFamilyMemberPubliclyTradedCompanyIndicator": false,
"SalesRevenueAmount": {
"@CurrencyISOAlpha3Code": "USD",
"@UnitOfSize": "Million",
"$": 0.92505
},
"DisplaySequence": 2
}
]
}
}
}
The problem I am running into is that some of the data I need (org Name, address, revenue etc) have special characters like $ and @ that are reserved in Apex, preventing the de-serialization from working properly when I create a class using https://json2apex.herokuapp.com/ . I cannot create data structures to store these values as Apex will not allow $ and @ in variable names and class names.
If anyone has any ideas or suggestions to create an Apex class to properly handle the deserialization that would be greatly appreciated. I am beginning to think I may have to use the JSON parser method to manually parse the response and create classes/data members accordingly.