SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

Hibernate architecture
Hibernate architectureHibernate architecture
Hibernate architectureAnurag
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET CoreAvanade Nederland
 
자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)

자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)
자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)

자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)
DK Lee
 
Flutter presentation.pptx
Flutter presentation.pptxFlutter presentation.pptx
Flutter presentation.pptxFalgunSorathiya
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewShahed Chowdhuri
 
OpenAPI 3.0, And What It Means for the Future of Swagger
OpenAPI 3.0, And What It Means for the Future of SwaggerOpenAPI 3.0, And What It Means for the Future of Swagger
OpenAPI 3.0, And What It Means for the Future of SwaggerSmartBear
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
Consumer-Driven Contract Testing
Consumer-Driven Contract TestingConsumer-Driven Contract Testing
Consumer-Driven Contract TestingPaulo Clavijo
 
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptx
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptxGetting started with Next.js - IM Tech Meetup - Oct 2022.pptx
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptxIlesh Mistry
 
자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020
자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020 자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020
자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020 AWSKRUG - AWS한국사용자모임
 
Learn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c AdministrationLearn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c AdministrationRevelation Technologies
 
Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트
Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트
Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트Atlassian 대한민국
 
IBM Datapower Security Scenario with JWS & JWE
IBM Datapower Security Scenario with JWS & JWEIBM Datapower Security Scenario with JWS & JWE
IBM Datapower Security Scenario with JWS & JWEsandipg123
 
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkTimothy Spann
 

Tendances (20)

Hibernate architecture
Hibernate architectureHibernate architecture
Hibernate architecture
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
Mediator pattern
Mediator patternMediator pattern
Mediator pattern
 
자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)

자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)
자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)

자바 웹 개발 시작하기 (10주차 : ㅌㅗㅇ ㅎㅏ ㄹㅏ)

 
Flutter presentation.pptx
Flutter presentation.pptxFlutter presentation.pptx
Flutter presentation.pptx
 
ASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with OverviewASP.NET Core MVC + Web API with Overview
ASP.NET Core MVC + Web API with Overview
 
OpenAPI 3.0, And What It Means for the Future of Swagger
OpenAPI 3.0, And What It Means for the Future of SwaggerOpenAPI 3.0, And What It Means for the Future of Swagger
OpenAPI 3.0, And What It Means for the Future of Swagger
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Consumer-Driven Contract Testing
Consumer-Driven Contract TestingConsumer-Driven Contract Testing
Consumer-Driven Contract Testing
 
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptx
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptxGetting started with Next.js - IM Tech Meetup - Oct 2022.pptx
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptx
 
자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020
자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020 자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020
자바를 잡아주는 GURU가 있다구!? - 우여명 (아이스크림에듀) :: AWS Community Day 2020
 
React
React React
React
 
Learn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c AdministrationLearn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c Administration
 
Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트
Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트
Confluence를 활용한 콘텐츠 협업 방법 - 모우소프트
 
IBM Datapower Security Scenario with JWS & JWE
IBM Datapower Security Scenario with JWS & JWEIBM Datapower Security Scenario with JWS & JWE
IBM Datapower Security Scenario with JWS & JWE
 
Mediator Design Pattern
Mediator Design PatternMediator Design Pattern
Mediator Design Pattern
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React Hooks
React HooksReact Hooks
React Hooks
 
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 

Dernier

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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Dernier (20)

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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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

Notes de l'éditeur

  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.