SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Motivation

                               Classic approaches

                               Better approaches



      Agenda



Make XML/JSON Parsing Simple
Developers not aware of
                               recent platform changes.

                               Google gives pointers to
                               obsolete APIs.

                               Obsolete APIs are slow and
                               hurt on governor limits like
  Motivation                   “script statements
                               consumption”

                               New APIs use platform
                               capabilities for resource
                               hungry tasks like parsing.

Why we are discussing this ?
Native Lib ?

               Provided by Force.com
               platform aka System libraries,
               like XMLStreamReader
               Doesn’t hurt on resources like
Native Lib     script statements
               consumption.
    vs
Apex Lib     Apex Lib ?

               Wrapper on Native Lib, like
               XMLDOM.cls
               Written from scratch in Apex
               only, like JSONObject.cls
XML Parsing
<books>

              <book author="Chatty">Foo
             bar</book>

              <book author="Sassy">Baz </
             book>

Sample XML   </books>
public class Book {

                              String name;

                              String author;

                          }

Apex Model



Parse XML to this Model
XMLStream Classes

               Native Lib
               Stream based approach to
               parse XML


  Classic    XMLDom.cls (OpenSource)
Approaches     Apex Lib, wrapper on above
               XMLStream classes
               Create in memory DOM for
               XML Structure.
               Written by Ron Hess
               (Salesforce)
Dom.Document/XmlNode
             Classes
              Native Lib
              Came in Spring’10 release
              DOM based approach to parse
              XML
  Better
Approaches   FastXmlDom (OpenSource)
              Apex Lib, wrapper on above
              Dom.XmlNode classes
              Exposes pretty common DOM
              API for XML Parsing
              Tested & used in many
              projects.
Over to sublime code snippet




Sample Code



Lets see some code about all of
       these approaches
Pros

                Native Lib (Not an Apex
                implementation)
                Heap/Memory efficient like
                usual stream parsers.

XmlStream       Good for big XML string, parse
                only the required part of XML.
 Classes      Cons

                Complex code to parse XML.
                Not so developer friendly
                Sometimes can consume lots
                of script statements in
  Pros/Cons     iterations for big XMLs.
Pros
               Simple W3C DOM library,
               which developers are used to
               of using in HTML DOM as well.
               Simple and more readable
               code for XML Parsing.
             Cons
XMLDOM.cls     Creates in memory DOM for
               complete XML structure, so
               heavy on heap
               Consumes too many script
               statements in the above
               process.
               Not suitable for large XML
               parsing.
Pros

               Native DOM Lib
               Relatively simpler to use as
               compared to
               XMLStreamReader.
 Dom class     Consumes least script
Document &     statements.
             Cons
 XmlNode
               DOM API is not following w3c
               model, so learning curve for
               developers.
               Mandates namespace
               usage, that complicates simple
               xml parsing.
Pros

                 Exposes W3C DOM API (no
                 learning curve for developers)
                 Simpler to use as compared to
                 XMLStreamReader and DOM
                 Classes.

FastXMLDom       Consumes less script
                 statements.
               Cons

                 An Apex Lib, so consumes a bit
                 more script statements and
                 heap as compared to
                 Dom.XmlNode
   Pros/Cons
JSON Parsing
JSONObject.cls

               Apex Lib
               Tokenizes the string to create
               in memory JSON Structure
               Written by Ron
  Classic      Hess(Salesforce)
             System.JSONParser
Approaches
               Native lib
               Streaming and token based
               parsing of JSON
JSON

              Native Lib
              Mapped strong and loose
              parsing with Apex UDT(User
              Defined Types) and
              Collections like Maps.
  Better
Approaches
JSONObject

               Not required and please don’t
               use it any more.
              JSONParser

               http://www.salesforce.com/us/
               developer/docs/apexcode/Con
Sample Code    tent/apex_methods_system_js
               onparser.htm
              JSON

               http://www.tgerm.com/2011/10
               /winter12-jsonparser-
               serialize.html
Pros

                   None as of now


                 Cons

                   Consumes script statements
JSONObject.cls     and heap for large JSON files
                   Not as stable as compared to
                   Native libs.
Pros

               Native lib, hurts less on
               resources.
               Good option when JSON
               automated
               serialization/deserialization
               fails.
JSONParser     Came with Winter’12 release
             Cons

               Complex code and less
               developer friendly way to
               parse.
Pros

         Native lib, hurts less on
         resources.
         Serialize/De-serialize big
         JSON strings in one line of
         code.
         Easy transformation of JSON
         from String > UDT and vice
         versa
JSON     Gives option of loose parsing
         to Maps i.e.
         deserializeUntyped()
         Came with winter’12 release
         Improved a bit with every next
         release
       Cons

         Special care if required if
         JSON contains reserved words
         or conflicting stuff with Apex.
Searching for solutions in this
               order

                 Consult platform guides, like
                 apex dev guide.
                 developer.force.com
                 Salesforce.stackexchange.com
                 Google


General Tips   Stay on latest and greatest
               API

                 Don’t download pdf for
                 documentation use online
                 guides.
                 Use latest API version of Apex
                 class and VF page when
                 creating new ones.
Q&A
Use “Apex Developer Guide” for
                                       native libs, like:

                                         XmlStreamReader
                                         Dom classes
                                         JSON Parser
                                         JSON
                                       XMLDOM.cls

                                         http://developer.force.com/projectpa
                                         ge?id=a0630000002ahp5AAA
   Resources                           Fast XML DOM

                                         http://code.google.com/p/apex-fast-
                                         xml-dom/
                                       JSONObject.cls

                                         http://code.google.com/p/apex-
You will get all the link, as I will     library/source/browse/trunk/JSONO
      share the slides                  bject/src/classes/JSONObject.cls
@abhinavguptas
Thanks !   www.tgerm.com

Weitere ähnliche Inhalte

Was ist angesagt?

Salesforce Communities
Salesforce CommunitiesSalesforce Communities
Salesforce CommunitiesSunil kumar
 
API Gateway How-To: The Many Ways to Apply the Gateway Pattern
API Gateway How-To: The Many Ways to Apply the Gateway PatternAPI Gateway How-To: The Many Ways to Apply the Gateway Pattern
API Gateway How-To: The Many Ways to Apply the Gateway PatternVMware Tanzu
 
Logic Apps reuse with microservices design
Logic Apps reuse with microservices designLogic Apps reuse with microservices design
Logic Apps reuse with microservices designBizTalk360
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootKashif Ali Siddiqui
 
Oracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer IntroductionOracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer IntroductionJeffrey T. Pollock
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API GatewayYohann Ciurlik
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API PlatformJohannes Ridderstedt
 
Two-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsTwo-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsSalesforce Developers
 
Secure Salesforce: External App Integrations
Secure Salesforce: External App IntegrationsSecure Salesforce: External App Integrations
Secure Salesforce: External App IntegrationsSalesforce Developers
 
How API Enablement Drives Legacy Modernization
How API Enablement Drives Legacy ModernizationHow API Enablement Drives Legacy Modernization
How API Enablement Drives Legacy ModernizationMuleSoft
 
Salesforce Online Training
Salesforce Online TrainingSalesforce Online Training
Salesforce Online TrainingKeylabs
 
MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes MuleSoft
 
Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Salesforce Developers
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesAraf Karsh Hamid
 

Was ist angesagt? (20)

Basecamp copenhagen B2C Commerce
Basecamp copenhagen B2C CommerceBasecamp copenhagen B2C Commerce
Basecamp copenhagen B2C Commerce
 
Salesforce Communities
Salesforce CommunitiesSalesforce Communities
Salesforce Communities
 
API Gateway How-To: The Many Ways to Apply the Gateway Pattern
API Gateway How-To: The Many Ways to Apply the Gateway PatternAPI Gateway How-To: The Many Ways to Apply the Gateway Pattern
API Gateway How-To: The Many Ways to Apply the Gateway Pattern
 
Logic Apps reuse with microservices design
Logic Apps reuse with microservices designLogic Apps reuse with microservices design
Logic Apps reuse with microservices design
 
Understanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring BootUnderstanding MicroSERVICE Architecture with Java & Spring Boot
Understanding MicroSERVICE Architecture with Java & Spring Boot
 
Oracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer IntroductionOracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer Introduction
 
Introduction to Kong API Gateway
Introduction to Kong API GatewayIntroduction to Kong API Gateway
Introduction to Kong API Gateway
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 
Two-Way Integration with Writable External Objects
Two-Way Integration with Writable External ObjectsTwo-Way Integration with Writable External Objects
Two-Way Integration with Writable External Objects
 
Secure Salesforce: External App Integrations
Secure Salesforce: External App IntegrationsSecure Salesforce: External App Integrations
Secure Salesforce: External App Integrations
 
How API Enablement Drives Legacy Modernization
How API Enablement Drives Legacy ModernizationHow API Enablement Drives Legacy Modernization
How API Enablement Drives Legacy Modernization
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 
Zuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne PlatformZuul @ Netflix SpringOne Platform
Zuul @ Netflix SpringOne Platform
 
Salesforce Online Training
Salesforce Online TrainingSalesforce Online Training
Salesforce Online Training
 
Salesforce APIs
Salesforce APIsSalesforce APIs
Salesforce APIs
 
MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes MuleSoft's Approach to Driving Customer Outcomes
MuleSoft's Approach to Driving Customer Outcomes
 
Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex!
 
Microservices Architecture & Testing Strategies
Microservices Architecture & Testing StrategiesMicroservices Architecture & Testing Strategies
Microservices Architecture & Testing Strategies
 
Grafana vs Kibana
Grafana vs KibanaGrafana vs Kibana
Grafana vs Kibana
 
Apigee Products Overview
Apigee Products OverviewApigee Products Overview
Apigee Products Overview
 

Andere mochten auch

Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsDaniel Ballinger
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsSalesforce Developers
 
Xml And JSON Java
Xml And JSON JavaXml And JSON Java
Xml And JSON JavaHenry Addo
 
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
Our API Evolution: From Metadata to Tooling API for Building Incredible AppsOur API Evolution: From Metadata to Tooling API for Building Incredible Apps
Our API Evolution: From Metadata to Tooling API for Building Incredible AppsDreamforce
 
手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務Mu Chun Wang
 

Andere mochten auch (9)

Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
 
Using the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service ClientsUsing the Tooling API to Generate Apex SOAP Web Service Clients
Using the Tooling API to Generate Apex SOAP Web Service Clients
 
Xml And JSON Java
Xml And JSON JavaXml And JSON Java
Xml And JSON Java
 
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
Our API Evolution: From Metadata to Tooling API for Building Incredible AppsOur API Evolution: From Metadata to Tooling API for Building Incredible Apps
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
 
手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務手把手教你如何串接 Log 到各種網路服務
手把手教你如何串接 Log 到各種網路服務
 
Dino's DEV Project
Dino's DEV ProjectDino's DEV Project
Dino's DEV Project
 
Xml parsing
Xml parsingXml parsing
Xml parsing
 
Parsing XML Data
Parsing XML DataParsing XML Data
Parsing XML Data
 
6 xml parsing
6   xml parsing6   xml parsing
6 xml parsing
 

Ähnlich wie Parsing XML & JSON in Apex

Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Espen Brækken
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Espen Brækken
 
Difference between xml and json
Difference between xml and jsonDifference between xml and json
Difference between xml and jsonUmar Ali
 
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancoukQ con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancoukRoger Xia
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaSynesso
 
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotDelphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotArnaud Bouchez
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2Marco Gralike
 
Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?mikaelbarbero
 
Speed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsSpeed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsMarko Gorički
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerVladimir Sedach
 
Understanding Dom
Understanding DomUnderstanding Dom
Understanding DomLiquidHub
 
Design Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformDesign Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformMarco Gralike
 
Moving from Relational to Document Store
Moving from Relational to Document StoreMoving from Relational to Document Store
Moving from Relational to Document StoreGraham Tackley
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroadJim Jones
 

Ähnlich wie Parsing XML & JSON in Apex (20)

Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
 
Difference between xml and json
Difference between xml and jsonDifference between xml and json
Difference between xml and json
 
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancoukQ con london2011-matthewwall-whyichosemongodbforguardiancouk
Q con london2011-matthewwall-whyichosemongodbforguardiancouk
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
ODF Mashups
ODF MashupsODF Mashups
ODF Mashups
 
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotDelphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 2
 
Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?Language Server Protocol - Why the Hype?
Language Server Protocol - Why the Hype?
 
Speed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and HandlebarsSpeed Up Your APEX Apps with JSON and Handlebars
Speed Up Your APEX Apps with JSON and Handlebars
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby on Rails
Ruby on Rails Ruby on Rails
Ruby on Rails
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
Avro
AvroAvro
Avro
 
Understanding Dom
Understanding DomUnderstanding Dom
Understanding Dom
 
Design Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will PerformDesign Concepts For Xml Applications That Will Perform
Design Concepts For Xml Applications That Will Perform
 
Moving from Relational to Document Store
Moving from Relational to Document StoreMoving from Relational to Document Store
Moving from Relational to Document Store
 
A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 

Mehr von Abhinav Gupta

What is Einstein Data Detect?
What is Einstein Data Detect?What is Einstein Data Detect?
What is Einstein Data Detect?Abhinav Gupta
 
Salesforce 2023 Recap
Salesforce 2023 RecapSalesforce 2023 Recap
Salesforce 2023 RecapAbhinav Gupta
 
Safeguarding Salesforce: Mastering Data Security with Data Mask
Safeguarding Salesforce: Mastering Data Security with Data MaskSafeguarding Salesforce: Mastering Data Security with Data Mask
Safeguarding Salesforce: Mastering Data Security with Data MaskAbhinav Gupta
 
🤖 Understanding 4 Waves of AI
🤖 Understanding 4 Waves of AI 🤖 Understanding 4 Waves of AI
🤖 Understanding 4 Waves of AI Abhinav Gupta
 
AI & Evolving Customer Trust Dynamics (1).pdf
AI & Evolving Customer Trust Dynamics  (1).pdfAI & Evolving Customer Trust Dynamics  (1).pdf
AI & Evolving Customer Trust Dynamics (1).pdfAbhinav Gupta
 
Salesforce Functions History - Launch to Retirement (2019-2023)
Salesforce Functions History - Launch to Retirement (2019-2023)Salesforce Functions History - Launch to Retirement (2019-2023)
Salesforce Functions History - Launch to Retirement (2019-2023)Abhinav Gupta
 
Unlocking the Puzzle of Modern Customer Wants.pdf
Unlocking the Puzzle of Modern  Customer Wants.pdfUnlocking the Puzzle of Modern  Customer Wants.pdf
Unlocking the Puzzle of Modern Customer Wants.pdfAbhinav Gupta
 
NFT Collectors - Understanding AI Puke Art
NFT Collectors - Understanding AI Puke ArtNFT Collectors - Understanding AI Puke Art
NFT Collectors - Understanding AI Puke ArtAbhinav Gupta
 
What’s Web3 for Salesforce?
What’s Web3 for Salesforce?What’s Web3 for Salesforce?
What’s Web3 for Salesforce?Abhinav Gupta
 
Generative AI Art - The Dark Side
Generative AI Art - The Dark SideGenerative AI Art - The Dark Side
Generative AI Art - The Dark SideAbhinav Gupta
 
Whats, Whys and Hows of NFTs?
Whats, Whys and Hows of NFTs?Whats, Whys and Hows of NFTs?
Whats, Whys and Hows of NFTs?Abhinav Gupta
 
Mental Peace at Work during Pandemic
Mental Peace at Work during PandemicMental Peace at Work during Pandemic
Mental Peace at Work during PandemicAbhinav Gupta
 
Salesforce restriction rules <2 min Summary
Salesforce restriction rules <2 min SummarySalesforce restriction rules <2 min Summary
Salesforce restriction rules <2 min SummaryAbhinav Gupta
 
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - SydneySimplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - SydneyAbhinav Gupta
 
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket PipelinesSalesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket PipelinesAbhinav Gupta
 
Building a layoff proof career
Building a layoff proof careerBuilding a layoff proof career
Building a layoff proof careerAbhinav Gupta
 
Fun with Jenkins & Salesforce
Fun with Jenkins & SalesforceFun with Jenkins & Salesforce
Fun with Jenkins & SalesforceAbhinav Gupta
 
Dreamforce 2015 Session - Angular-ifying your visualforce pages
Dreamforce 2015 Session - Angular-ifying your visualforce pagesDreamforce 2015 Session - Angular-ifying your visualforce pages
Dreamforce 2015 Session - Angular-ifying your visualforce pagesAbhinav Gupta
 
Intro to Apex - Salesforce Force Friday Webinar
Intro to Apex - Salesforce Force Friday Webinar Intro to Apex - Salesforce Force Friday Webinar
Intro to Apex - Salesforce Force Friday Webinar Abhinav Gupta
 
Building Chrome Extensions For Salesforce
Building Chrome Extensions  For SalesforceBuilding Chrome Extensions  For Salesforce
Building Chrome Extensions For SalesforceAbhinav Gupta
 

Mehr von Abhinav Gupta (20)

What is Einstein Data Detect?
What is Einstein Data Detect?What is Einstein Data Detect?
What is Einstein Data Detect?
 
Salesforce 2023 Recap
Salesforce 2023 RecapSalesforce 2023 Recap
Salesforce 2023 Recap
 
Safeguarding Salesforce: Mastering Data Security with Data Mask
Safeguarding Salesforce: Mastering Data Security with Data MaskSafeguarding Salesforce: Mastering Data Security with Data Mask
Safeguarding Salesforce: Mastering Data Security with Data Mask
 
🤖 Understanding 4 Waves of AI
🤖 Understanding 4 Waves of AI 🤖 Understanding 4 Waves of AI
🤖 Understanding 4 Waves of AI
 
AI & Evolving Customer Trust Dynamics (1).pdf
AI & Evolving Customer Trust Dynamics  (1).pdfAI & Evolving Customer Trust Dynamics  (1).pdf
AI & Evolving Customer Trust Dynamics (1).pdf
 
Salesforce Functions History - Launch to Retirement (2019-2023)
Salesforce Functions History - Launch to Retirement (2019-2023)Salesforce Functions History - Launch to Retirement (2019-2023)
Salesforce Functions History - Launch to Retirement (2019-2023)
 
Unlocking the Puzzle of Modern Customer Wants.pdf
Unlocking the Puzzle of Modern  Customer Wants.pdfUnlocking the Puzzle of Modern  Customer Wants.pdf
Unlocking the Puzzle of Modern Customer Wants.pdf
 
NFT Collectors - Understanding AI Puke Art
NFT Collectors - Understanding AI Puke ArtNFT Collectors - Understanding AI Puke Art
NFT Collectors - Understanding AI Puke Art
 
What’s Web3 for Salesforce?
What’s Web3 for Salesforce?What’s Web3 for Salesforce?
What’s Web3 for Salesforce?
 
Generative AI Art - The Dark Side
Generative AI Art - The Dark SideGenerative AI Art - The Dark Side
Generative AI Art - The Dark Side
 
Whats, Whys and Hows of NFTs?
Whats, Whys and Hows of NFTs?Whats, Whys and Hows of NFTs?
Whats, Whys and Hows of NFTs?
 
Mental Peace at Work during Pandemic
Mental Peace at Work during PandemicMental Peace at Work during Pandemic
Mental Peace at Work during Pandemic
 
Salesforce restriction rules <2 min Summary
Salesforce restriction rules <2 min SummarySalesforce restriction rules <2 min Summary
Salesforce restriction rules <2 min Summary
 
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - SydneySimplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
Simplified CI/CD Flows for Salesforce via SFDX - Downunder Dreamin - Sydney
 
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket PipelinesSalesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
Salesforce CI (Continuous Integration) - SFDX + Bitbucket Pipelines
 
Building a layoff proof career
Building a layoff proof careerBuilding a layoff proof career
Building a layoff proof career
 
Fun with Jenkins & Salesforce
Fun with Jenkins & SalesforceFun with Jenkins & Salesforce
Fun with Jenkins & Salesforce
 
Dreamforce 2015 Session - Angular-ifying your visualforce pages
Dreamforce 2015 Session - Angular-ifying your visualforce pagesDreamforce 2015 Session - Angular-ifying your visualforce pages
Dreamforce 2015 Session - Angular-ifying your visualforce pages
 
Intro to Apex - Salesforce Force Friday Webinar
Intro to Apex - Salesforce Force Friday Webinar Intro to Apex - Salesforce Force Friday Webinar
Intro to Apex - Salesforce Force Friday Webinar
 
Building Chrome Extensions For Salesforce
Building Chrome Extensions  For SalesforceBuilding Chrome Extensions  For Salesforce
Building Chrome Extensions For Salesforce
 

Kürzlich hochgeladen

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Kürzlich hochgeladen (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Parsing XML & JSON in Apex

  • 1.
  • 2. Motivation Classic approaches Better approaches Agenda Make XML/JSON Parsing Simple
  • 3. Developers not aware of recent platform changes. Google gives pointers to obsolete APIs. Obsolete APIs are slow and hurt on governor limits like Motivation “script statements consumption” New APIs use platform capabilities for resource hungry tasks like parsing. Why we are discussing this ?
  • 4. Native Lib ? Provided by Force.com platform aka System libraries, like XMLStreamReader Doesn’t hurt on resources like Native Lib script statements consumption. vs Apex Lib Apex Lib ? Wrapper on Native Lib, like XMLDOM.cls Written from scratch in Apex only, like JSONObject.cls
  • 6. <books> <book author="Chatty">Foo bar</book> <book author="Sassy">Baz </ book> Sample XML </books>
  • 7. public class Book { String name; String author; } Apex Model Parse XML to this Model
  • 8. XMLStream Classes Native Lib Stream based approach to parse XML Classic XMLDom.cls (OpenSource) Approaches Apex Lib, wrapper on above XMLStream classes Create in memory DOM for XML Structure. Written by Ron Hess (Salesforce)
  • 9. Dom.Document/XmlNode Classes Native Lib Came in Spring’10 release DOM based approach to parse XML Better Approaches FastXmlDom (OpenSource) Apex Lib, wrapper on above Dom.XmlNode classes Exposes pretty common DOM API for XML Parsing Tested & used in many projects.
  • 10. Over to sublime code snippet Sample Code Lets see some code about all of these approaches
  • 11. Pros Native Lib (Not an Apex implementation) Heap/Memory efficient like usual stream parsers. XmlStream Good for big XML string, parse only the required part of XML. Classes Cons Complex code to parse XML. Not so developer friendly Sometimes can consume lots of script statements in Pros/Cons iterations for big XMLs.
  • 12. Pros Simple W3C DOM library, which developers are used to of using in HTML DOM as well. Simple and more readable code for XML Parsing. Cons XMLDOM.cls Creates in memory DOM for complete XML structure, so heavy on heap Consumes too many script statements in the above process. Not suitable for large XML parsing.
  • 13. Pros Native DOM Lib Relatively simpler to use as compared to XMLStreamReader. Dom class Consumes least script Document & statements. Cons XmlNode DOM API is not following w3c model, so learning curve for developers. Mandates namespace usage, that complicates simple xml parsing.
  • 14. Pros Exposes W3C DOM API (no learning curve for developers) Simpler to use as compared to XMLStreamReader and DOM Classes. FastXMLDom Consumes less script statements. Cons An Apex Lib, so consumes a bit more script statements and heap as compared to Dom.XmlNode Pros/Cons
  • 16. JSONObject.cls Apex Lib Tokenizes the string to create in memory JSON Structure Written by Ron Classic Hess(Salesforce) System.JSONParser Approaches Native lib Streaming and token based parsing of JSON
  • 17. JSON Native Lib Mapped strong and loose parsing with Apex UDT(User Defined Types) and Collections like Maps. Better Approaches
  • 18. JSONObject Not required and please don’t use it any more. JSONParser http://www.salesforce.com/us/ developer/docs/apexcode/Con Sample Code tent/apex_methods_system_js onparser.htm JSON http://www.tgerm.com/2011/10 /winter12-jsonparser- serialize.html
  • 19. Pros None as of now Cons Consumes script statements JSONObject.cls and heap for large JSON files Not as stable as compared to Native libs.
  • 20. Pros Native lib, hurts less on resources. Good option when JSON automated serialization/deserialization fails. JSONParser Came with Winter’12 release Cons Complex code and less developer friendly way to parse.
  • 21. Pros Native lib, hurts less on resources. Serialize/De-serialize big JSON strings in one line of code. Easy transformation of JSON from String > UDT and vice versa JSON Gives option of loose parsing to Maps i.e. deserializeUntyped() Came with winter’12 release Improved a bit with every next release Cons Special care if required if JSON contains reserved words or conflicting stuff with Apex.
  • 22. Searching for solutions in this order Consult platform guides, like apex dev guide. developer.force.com Salesforce.stackexchange.com Google General Tips Stay on latest and greatest API Don’t download pdf for documentation use online guides. Use latest API version of Apex class and VF page when creating new ones.
  • 23. Q&A
  • 24. Use “Apex Developer Guide” for native libs, like: XmlStreamReader Dom classes JSON Parser JSON XMLDOM.cls http://developer.force.com/projectpa ge?id=a0630000002ahp5AAA Resources Fast XML DOM http://code.google.com/p/apex-fast- xml-dom/ JSONObject.cls http://code.google.com/p/apex- You will get all the link, as I will library/source/browse/trunk/JSONO share the slides  bject/src/classes/JSONObject.cls
  • 25. @abhinavguptas Thanks ! www.tgerm.com

Hinweis der Redaktion

  1. Your introductory or title slide should convey the overall “feeling” and focus of your presentation. For instance, I typically present about small-business trends, new business ideas, growth opportunities or other positive trends. In this sample presentation, I’m talking about new business ideas, so I used a sun graphic in this slide template to convey a positive feeling. Personalize this slide template with your company’s logo. To add a logo to all slides, place it on the Slide Master. To access the Slide Master, on the Themes tab of the Ribbon, click Edit Master and then click Slide Master.Disclaimer: You understand that Microsoft does not endorse or control the content provided in the following presentation. Microsoft provides this content to you for informational purposes only; it is not intended to be relied upon as business or financial advice. Microsoft does not guarantee or otherwise warrant the accuracy or validity of this information and encourages you to consult with a business or financial professional as appropriate.RIEVA LESONSKY Founder and President, GrowBiz Media RievaLesonsky is founder and president of GrowBiz Media, a content and consulting company specializing in covering small businesses and entrepreneurship. A nationally known speaker and authority on entrepreneurship, Lesonsky has been covering America’s entrepreneurs for nearly 30 years. Before co-founding GrowBiz Media, Lesonsky was Editorial Director of Entrepreneur Magazine.