Skip to main content
My JSON String is not getting parsed in Visual force page. It is working just fine in standalone HTML Jquery test page.

my JSON is:

 

{"CompanyResponse":{"@ServiceVersionNumber":"6.1","TransactionDetail":{"ApplicationTransactionID":"Id-fc6a4756f6b52b00f2ae0e009fcc2af3-1","ServiceTransactionID":"Id-fc6a4756f6b52b00f2ae0e009fcc2af3-1","TransactionTimestamp":"2015-11-14T17:10:20"},"TransactionResult":{"SeverityText":"Information","ResultID":"CM000","ResultText":"Success"},"FindCompanyResponseDetail":{"CandidateMatchedQuantity":1,"CandidateReturnedQuantity":1,"FindCandidate":[{"DUNSNumber":"884745530","OrganizationPrimaryName":{"OrganizationName":{"$":"AMAZON.COM, INC."}},"TradeStyleName":[{"OrganizationName":{"$":"Amazon.Com"}}],"MarketabilityIndicator":true,"PrimaryAddress":{"StreetAddressLine":[{"LineText":"410 Terry Ave N"}],"PrimaryTownName":"Seattle","CountryISOAlpha2Code":"US","PostalCode":"98109","PostalCodeExtensionCode":"5210","TerritoryOfficialName":"Washington","TerritoryAbbreviatedName":"WA","MetropolitanStatisticalAreaUSCensusCode":["42660"]},"TelephoneNumber":{"TelecommunicationNumber":"2062661000"},"FacsimileNumber":{"TelecommunicationNumber":"2062664952"},"FamilyTreeMemberRole":[{"FamilyTreeMemberRoleText":{"@CodeValue":12771,"$":"Headquarters"}}],"StandaloneOrganizationIndicator":false,"IndustryCode":[{"@TypeText":"D&B Standard Industry Code","@CodeValue":3599,"IndustryCode":{"$":"59610000"},"IndustryCodeDescription":[{"@IndustryCodeDescriptionLengthCode":2121,"$":"CATALOG,MAIL HOUSES"}]}],"ConsolidatedEmployeeDetails":{"TotalEmployeeQuantity":154100},"PubliclyTradedCompanyIndicator":true,"UpwardFamilyMemberPubliclyTradedCompanyIndicator":true,"StockExchangeDetails":[{"StockExchangeTickerName":"AMZN"},{"StockExchangeTickerName":"AMZ"},{"StockExchangeName":{"@CodeValue":23343,"$":"Dusseldorf Stock Exchange"},"StockExchangeTickerName":"AMZ"},{"StockExchangeName":{"@CodeValue":23344,"$":"Frankfurt Stock Exchange"},"StockExchangeTickerName":"AMZ"},{"StockExchangeName":{"@CodeValue":23345,"$":"Hamburg Stock Exchange"},"StockExchangeTickerName":"AMZ"},{"StockExchangeName":{"@CodeValue":23357,"$":"BMV"},"StockExchangeTickerName":"AMZN"},{"StockExchangeName":{"@CodeValue":23360,"$":"Borse Munchen"},"StockExchangeTickerName":"AMZ"},{"StockExchangeName":{"@CodeValue":23367,"$":"SSE"},"StockExchangeTickerName":"AMZN"},{"StockExchangeName":{"@CodeValue":23378,"$":"SIX Swiss Exchange"},"StockExchangeTickerName":"US1760"},{"StockExchangeName":{"@CodeValue":23378,"$":"SIX Swiss Exchange"},"StockExchangeTickerName":"US1759"},{"StockExchangeName":{"@CodeValue":23378,"$":"SIX Swiss Exchange"},"StockExchangeTickerName":"US1758"},{"StockExchangeName":{"@CodeValue":23398,"$":"BVL"},"StockExchangeTickerName":"AMZN"},{"StockExchangeTickerName":"AMA-U"},{"StockExchangeTickerName":"AMZNn"},{"StockExchangeTickerName":"AMZN"},{"StockExchangeTickerName":"AMZN"},{"StockExchangeTickerName":"AMZN"},{"StockExchangeTickerName":"AMZN"},{"StockExchangeTickerName":"AMZO34"},{"StockExchangeTickerName":"AMZF"},{"StockExchangeTickerName":"AMZN"},{"StockExchangeName":{"@CodeValue":23338,"$":"BVC (Colombia)"},"StockExchangeTickerName":"AMZN"}],"SalesRevenueAmount":{"@CurrencyISOAlpha3Code":"USD","@UnitOfSize":"Million","$":88988},"DisplaySequence":1}]}}}

Visual force code is:

 

CompanyController.FindCompany( j$('⌗input').val(),function(result,event){

alert(result); //gives alert message of JSON string result from controller.

var parsedRes=jQuery.parseJSON(result);

var parsedRes2=JSON.parse(result);

alert(parsedRes); //not working

alert(parsedRes2);// not working

i added the script like this

 

<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" />

 
1 answer
  1. Nov 14, 2015, 9:20 PM

    Hey Arun,

    If you will use only the below part of code then it will work fine, try it.

    CompanyController.FindCompany( j$('⌗input').val(),function(result,event){

    alert(result); //gives alert message of JSON string result from controller.

    var parsedRes2=JSON.parse(result);

    alert(parsedRes2);// not working

0/9000