function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
raz rraz r 

How to parse the below json

I want to parse the below json and return the Value from DailyApiRequests Max into a Integer.

"ConcurrentSyncReportRuns":{"Max":20,"Remaining":20},
        "DailyAnalyticsDataflowJobExecutions":{"Max":40,"Remaining":40},
        "DailyApiRequests":{"Max":16124600,"Remaining":16123983}

Please helep me .Urgent!!!!
Niraj Kr SinghNiraj Kr Singh
Hi Raj,
 Your correct json format is like this:
{
    "title": {
        "ConcurrentSyncReportRuns": {
            "Max": 20,
            "Remaining": 20
        },
        "DailyAnalyticsDataflowJobExecutions": {
            "Max": 40,
            "Remaining": 40
        },
        "DailyApiRequests": {
            "Max": 16124600,
            "Remaining": 16123983
        }
    }
}
-----------------------
And your corresponding class is:
public class fromJSON{
	public cls_title title;
	class cls_title {
		public cls_ConcurrentSyncReportRuns ConcurrentSyncReportRuns;
		public cls_DailyAnalyticsDataflowJobExecutions DailyAnalyticsDataflowJobExecutions;
		public cls_DailyApiRequests DailyApiRequests;
	}
	class cls_ConcurrentSyncReportRuns {
		public Integer Max;	//20
		public Integer Remaining;	//20
	}
	class cls_DailyAnalyticsDataflowJobExecutions {
		public Integer Max;	//40
		public Integer Remaining;	//40
	}
	class cls_DailyApiRequests {
		public Integer Max;	//16124600
		public Integer Remaining;	//16123983
	}
        public static fromJSON parse(String json){
		return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
	}
}

Plz let me know if it works

Mark your ans to help others
Thanks
Niraj
 
Niraj Kr SinghNiraj Kr Singh
And in your main class use like this
Public class MainClass {
     Public void jsondata() { 
        String strJSON = ' your above json string ';
         fromJSON objJSON =  (fromJSON) JSON.deserialize(strJSON, fromJSON.class);
     }
}
Hope it will work ...
raz rraz r
Hi Niraj,

I want to get the  DailyApiRequests Max value into a Integer.
Niraj Kr SinghNiraj Kr Singh
Hi Raj,

Note: One small update needed in this above Class: fromJSON. Make all Inner class public and then execute this below code from developer console. You will get your DailyApiRequests Max value into a Integer.
 
String strJSON = '{"title": {"ConcurrentSyncReportRuns": {"Max": 20,"Remaining": 20},"DailyAnalyticsDataflowJobExecutions": {"Max": 40,"Remaining": 40},"DailyApiRequests": {"Max": 16124600,"Remaining": 16123983}}}';
fromJSON objJSON =  (fromJSON) JSON.deserialize(strJSON, fromJSON.class);
Integer maxValue = objJSON.title.DailyApiRequests.Max;
System.debug('---Value---' + maxValue);
Please let me know if it works for you.
 
raz rraz r
Thanks Niraj ..It works!
Niraj Kr SinghNiraj Kr Singh
Hi Raz,

Cheers !!

Mark the ans so that it can help others as well.

Thanks
Niraj
 
lavanya g 9lavanya g 9
Hi @Niraj Kr Singh ,

I am getting attempt to derefernce for my json , could you please help meout for the same.

here is my json


'{"AnalyticsExternalDataSizeMB":{"Max":40960,"Remaining":40960},"ConcurrentAsyncGetReportInstances":{"Max":200,"Remaining":200},"ConcurrentSyncReportRuns":{"Max":20,"Remaining":20},"DailyAnalyticsDataflowJobExecutions":{"Max":60,"Remaining":60},"DailyAnalyticsUploadedFilesSizeMB":{"Max":51200,"Remaining":51200},"DailyApiRequests":{"Max":492840000,"Remaining":492839704,"Ant Migration Tool":{"Max":0,"Remaining":0},"BFM Mulesoft":{"Max":0,"Remaining":0},"CPQ Integration User Connected App":{"Max":0,"Remaining":0},"Chatter Desktop":{"Max":0,"Remaining":0},"Chatter Mobile for BlackBerry":{"Max":0,"Remaining":0},"Dataloader Bulk":{"Max":0,"Remaining":0},"Dataloader Partner":{"Max":0,"Remaining":0},"Easy2Find_DEV":{"Max":0,"Remaining":0},"Easy2Find_PREPROD":{"Max":0,"Remaining":0},"Easy2Find_PROD":{"Max":0,"Remaining":0},"Elastic ELK":{"Max":0,"Remaining":0},"Force.com IDE":{"Max":0,"Remaining":0},"FourAcres":{"Max":0,"Remaining":0},"Inside.Unilever":{"Max":0,"Remaining":0},"LiveMessage for Salesforce":{"Max":0,"Remaining":0},"LiveText for Salesforce (QA)":{"Max":0,"Remaining":0},"MapAnything":{"Max":0,"Remaining":0},"MapAnything Territory Management":{"Max":0,"Remaining":0},"MuleSoft Vendor BPM":{"Max":0,"Remaining":0},"News Centre":{"Max":0,"Remaining":0},"News Centre QA":{"Max":0,"Remaining":0},"Prod_Heroku_Mulesoft":{"Max":0,"Remaining":0},"Prod_Heroku_Postman":{"Max":0,"Remaining":0},"Prod_Heroku_Wave":{"Max":0,"Remaining":0},"SMS Magic Interact":{"Max":0,"Remaining":0},"Salesforce Chatter":{"Max":0,"Remaining":0},"Salesforce Files":{"Max":0,"Remaining":0},"Salesforce Mobile Dashboards":{"Max":0,"Remaining":0},"Salesforce Touch":{"Max":0,"Remaining":0},"Salesforce for Android":{"Max":0,"Remaining":0},"Salesforce for Outlook":{"Max":0,"Remaining":0},"Salesforce for iOS":{"Max":0,"Remaining":0},"SalesforceA":{"Max":0,"Remaining":0},"SalesforceA for Android":{"Max":0,"Remaining":0},"SalesforceA for iOS":{"Max":0,"Remaining":0},"Sharepoint Online":{"Max":0,"Remaining":0},"Showpad App":{"Max":0,"Remaining":0},"Showpad Salesforce Integration":{"Max":0,"Remaining":0},"Teamsites.Unilever":{"Max":0,"Remaining":0},"Wings 2.0":{"Max":0,"Remaining":0},"Workbench":{"Max":0,"Remaining":0},"Your News":{"Max":0,"Remaining":0},"getAbstract":{"Max":0,"Remaining":0}},"DailyAsyncApexExecutions":{"Max":30425000,"Remaining":30424998},"DailyBulkApiRequests":{"Max":10000,"Remaining":10000,"Ant Migration Tool":{"Max":0,"Remaining":0},"BFM Mulesoft":{"Max":0,"Remaining":0},"CPQ Integration User Connected App":{"Max":0,"Remaining":0},"Chatter Desktop":{"Max":0,"Remaining":0},"Chatter Mobile for BlackBerry":{"Max":0,"Remaining":0},"Dataloader Bulk":{"Max":0,"Remaining":0},"Dataloader Partner":{"Max":0,"Remaining":0},"Easy2Find_DEV":{"Max":0,"Remaining":0},"Easy2Find_PREPROD":{"Max":0,"Remaining":0},"Easy2Find_PROD":{"Max":0,"Remaining":0},"Elastic ELK":{"Max":0,"Remaining":0},"Force.com IDE":{"Max":0,"Remaining":0},"FourAcres":{"Max":0,"Remaining":0},"Inside.Unilever":{"Max":0,"Remaining":0},"LiveMessage for Salesforce":{"Max":0,"Remaining":0},"LiveText for Salesforce (QA)":{"Max":0,"Remaining":0},"MapAnything":{"Max":0,"Remaining":0},"MapAnything Territory Management":{"Max":0,"Remaining":0},"MuleSoft Vendor BPM":{"Max":0,"Remaining":0},"News Centre":{"Max":0,"Remaining":0},"News Centre QA":{"Max":0,"Remaining":0},"Prod_Heroku_Mulesoft":{"Max":0,"Remaining":0},"Prod_Heroku_Postman":{"Max":0,"Remaining":0},"Prod_Heroku_Wave":{"Max":0,"Remaining":0},"SMS Magic Interact":{"Max":0,"Remaining":0},"Salesforce Chatter":{"Max":0,"Remaining":0},"Salesforce Files":{"Max":0,"Remaining":0},"Salesforce Mobile Dashboards":{"Max":0,"Remaining":0},"Salesforce Touch":{"Max":0,"Remaining":0},"Salesforce for Android":{"Max":0,"Remaining":0},"Salesforce for Outlook":{"Max":0,"Remaining":0},"Salesforce for iOS":{"Max":0,"Remaining":0},"SalesforceA":{"Max":0,"Remaining":0},"SalesforceA for Android":{"Max":0,"Remaining":0},"SalesforceA for iOS":{"Max":0,"Remaining":0},"Sharepoint Online":{"Max":0,"Remaining":0},"Showpad App":{"Max":0,"Remaining":0},"Showpad Salesforce Integration":{"Max":0,"Remaining":0},"Teamsites.Unilever":{"Max":0,"Remaining":0},"Wings 2.0":{"Max":0,"Remaining":0},"Workbench":{"Max":0,"Remaining":0},"Your News":{"Max":0,"Remaining":0},"getAbstract":{"Max":0,"Remaining":0}},"DailyDurableGenericStreamingApiEvents":{"Max":1000000,"Remaining":1000000},"DailyDurableStreamingApiEvents":{"Max":1000000,"Remaining":1000000},"DailyGenericStreamingApiEvents":{"Max":10000,"Remaining":10000,"Ant Migration Tool":{"Max":0,"Remaining":0},"BFM Mulesoft":{"Max":0,"Remaining":0},"CPQ Integration User Connected App":{"Max":0,"Remaining":0},"Chatter Desktop":{"Max":0,"Remaining":0},"Chatter Mobile for BlackBerry":{"Max":0,"Remaining":0},"Dataloader Bulk":{"Max":0,"Remaining":0},"Dataloader Partner":{"Max":0,"Remaining":0},"Easy2Find_DEV":{"Max":0,"Remaining":0},"Easy2Find_PREPROD":{"Max":0,"Remaining":0},"Easy2Find_PROD":{"Max":0,"Remaining":0},"Elastic ELK":{"Max":0,"Remaining":0},"Force.com IDE":{"Max":0,"Remaining":0},"FourAcres":{"Max":0,"Remaining":0},"Inside.Unilever":{"Max":0,"Remaining":0},"LiveMessage for Salesforce":{"Max":0,"Remaining":0},"LiveText for Salesforce (QA)":{"Max":0,"Remaining":0},"MapAnything":{"Max":0,"Remaining":0},"MapAnything Territory Management":{"Max":0,"Remaining":0},"MuleSoft Vendor BPM":{"Max":0,"Remaining":0},"News Centre":{"Max":0,"Remaining":0},"News Centre QA":{"Max":0,"Remaining":0},"Prod_Heroku_Mulesoft":{"Max":0,"Remaining":0},"Prod_Heroku_Postman":{"Max":0,"Remaining":0},"Prod_Heroku_Wave":{"Max":0,"Remaining":0},"SMS Magic Interact":{"Max":0,"Remaining":0},"Salesforce Chatter":{"Max":0,"Remaining":0},"Salesforce Files":{"Max":0,"Remaining":0},"Salesforce Mobile Dashboards":{"Max":0,"Remaining":0},"Salesforce Touch":{"Max":0,"Remaining":0},"Salesforce for Android":{"Max":0,"Remaining":0},"Salesforce for Outlook":{"Max":0,"Remaining":0},"Salesforce for iOS":{"Max":0,"Remaining":0},"SalesforceA":{"Max":0,"Remaining":0},"SalesforceA for Android":{"Max":0,"Remaining":0},"SalesforceA for iOS":{"Max":0,"Remaining":0},"Sharepoint Online":{"Max":0,"Remaining":0},"Showpad App":{"Max":0,"Remaining":0},"Showpad Salesforce Integration":{"Max":0,"Remaining":0},"Teamsites.Unilever":{"Max":0,"Remaining":0},"Wings 2.0":{"Max":0,"Remaining":0},"Workbench":{"Max":0,"Remaining":0},"Your News":{"Max":0,"Remaining":0},"getAbstract":{"Max":0,"Remaining":0}},"DailyStandardVolumePlatformEvents":{"Max":50000,"Remaining":50000},"DailyStreamingApiEvents":{"Max":1000000,"Remaining":999983,"Ant Migration Tool":{"Max":0,"Remaining":0},"BFM Mulesoft":{"Max":0,"Remaining":0},"CPQ Integration User Connected App":{"Max":0,"Remaining":0},"Chatter Desktop":{"Max":0,"Remaining":0},"Chatter Mobile for BlackBerry":{"Max":0,"Remaining":0},"Dataloader Bulk":{"Max":0,"Remaining":0},"Dataloader Partner":{"Max":0,"Remaining":0},"Easy2Find_DEV":{"Max":0,"Remaining":0},"Easy2Find_PREPROD":{"Max":0,"Remaining":0},"Easy2Find_PROD":{"Max":0,"Remaining":0},"Elastic ELK":{"Max":0,"Remaining":0},"Force.com IDE":{"Max":0,"Remaining":0},"FourAcres":{"Max":0,"Remaining":0},"Inside.Unilever":{"Max":0,"Remaining":0},"LiveMessage for Salesforce":{"Max":0,"Remaining":0},"LiveText for Salesforce (QA)":{"Max":0,"Remaining":0},"MapAnything":{"Max":0,"Remaining":0},"MapAnything Territory Management":{"Max":0,"Remaining":0},"MuleSoft Vendor BPM":{"Max":0,"Remaining":0},"News Centre":{"Max":0,"Remaining":0},"News Centre QA":{"Max":0,"Remaining":0},"Prod_Heroku_Mulesoft":{"Max":0,"Remaining":0},"Prod_Heroku_Postman":{"Max":0,"Remaining":0},"Prod_Heroku_Wave":{"Max":0,"Remaining":0},"SMS Magic Interact":{"Max":0,"Remaining":0},"Salesforce Chatter":{"Max":0,"Remaining":0},"Salesforce Files":{"Max":0,"Remaining":0},"Salesforce Mobile Dashboards":{"Max":0,"Remaining":0},"Salesforce Touch":{"Max":0,"Remaining":0},"Salesforce for Android":{"Max":0,"Remaining":0},"Salesforce for Outlook":{"Max":0,"Remaining":0},"Salesforce for iOS":{"Max":0,"Remaining":0},"SalesforceA":{"Max":0,"Remaining":0},"SalesforceA for Android":{"Max":0,"Remaining":0},"SalesforceA for iOS":{"Max":0,"Remaining":0},"Sharepoint Online":{"Max":0,"Remaining":0},"Showpad App":{"Max":0,"Remaining":0},"Showpad Salesforce Integration":{"Max":0,"Remaining":0},"Teamsites.Unilever":{"Max":0,"Remaining":0},"Wings 2.0":{"Max":0,"Remaining":0},"Workbench":{"Max":0,"Remaining":0},"Your News":{"Max":0,"Remaining":0},"getAbstract":{"Max":0,"Remaining":0}},"DailyWorkflowEmails":{"Max":2000000,"Remaining":2000000},"DataStorageMB":{"Max":200,"Remaining":-19},"DurableStreamingApiConcurrentClients":{"Max":2000,"Remaining":2000},"FileStorageMB":{"Max":200,"Remaining":194},"HourlyAsyncReportRuns":{"Max":1200,"Remaining":1200},"HourlyDashboardRefreshes":{"Max":200,"Remaining":200},"HourlyDashboardResults":{"Max":5000,"Remaining":5000},"HourlyDashboardStatuses":{"Max":999999999,"Remaining":999999999},"HourlyLongTermIdMapping":{"Max":100000,"Remaining":100000},"HourlyODataCallout":{"Max":100000,"Remaining":100000},"HourlyShortTermIdMapping":{"Max":100000,"Remaining":100000},"HourlySyncReportRuns":{"Max":500,"Remaining":500},"HourlyTimeBasedWorkflow":{"Max":50,"Remaining":50},"MassEmail":{"Max":5000,"Remaining":5000},"MonthlyPlatformEvents":{"Max":1500000,"Remaining":1500000},"Package2VersionCreates":{"Max":6,"Remaining":6},"PermissionSets":{"Max":1500,"Remaining":1115,"CreateCustom":{"Max":1000,"Remaining":651}},"SingleEmail":{"Max":6000,"Remaining":6000},"StreamingApiConcurrentClients":{"Max":2000,"Remaining":2000}}'