Activity › Forums › Salesforce® Discussions › How to get Salesforce Visualforce page output as JSON?
-
How to get Salesforce Visualforce page output as JSON?
Posted by Aman on September 22, 2018 at 5:01 PMHow to get Salesforce Visualforce page output as JSON?
Parul replied 7 years, 7 months ago 3 Members · 3 Replies -
3 Replies
-
<apex:page controller=”ControllerName” contentType=”application/x-JavaScript; charset=utf-8″ showHeader=”false” standardStylesheets=”false” sidebar=”false”>
{!jsonString}
</apex:page> - [adinserter block='9']
-
Output Visualforce page as JSON Data:
To output the Visualforce page as JSON Data following point needs to be taken care,
contentType should be “application/x-JavaScript; charset=utf-8” (Note that i have not specified it as json although valid MIME type available for JSON in HTML)
showHeader attribute should be false.
standardStylesheets attribute should be false.
sidebar attribute should be false.
While calling the VF page always specify explicitly that we don’t need Page editor tool of the Salesforce using core.apexpages.devmode.url=0.
Source code for VF:<apex:page controller=”GanttChartData” contentType=”application/x-JavaScript; charset=utf-8″ showHeader=”false” standardStylesheets=”false” sidebar=”false”>
{!jsonString}</apex:page>
-
<apex:page controller=”JSONGenerator” contentType=”application/json; charset=utf-8″ showHeader=”false” standardStylesheets=”false” sidebar=”false”>
{!jsonStr}
</apex:page>
Log In to reply.