SlideShare a Scribd company logo
Hi!
I HATE JSON
{ “users”: [
{ “name”: “Joe” },
{ “name”: “Katy” },
]}
{“users”:[{ “name”:“Joe” },{ “name”:“Katy” }]}
my $var = { users => [
{ name => ‘Joe’ },
{ name => ‘Katy’ },
]
};
foreach my $user @{ $var->{ users } } {
…
}
Parsing JSON gives you this
Access to the data is like this
Working with complex datastructures:
{ users => [
{ name => ‘Joe’ },
{ name => ‘Katy’ },
]
}
USERLIST
USER
MooseX::DataModel
Why not express the structure like this?
package UserList;
use MooseX::DataModel;
array users (isa => ‘User’);
1;
package User;
use MooseX::DataModel;
key name => (isa => ‘Str’, required => 1);
1;
my $ul =UserList->parse($json);
say $ul->users->[0]->name;
This even validates the JSON to the schema!
We can even tack methods on the objects!
package UserList;
use MooseX::DataModel;
array users (isa => ‘User’);
sub send_mail_to_all { … for ($self->users) { … } … };
1;
package User;
key name => (isa => ‘Str’, required => 1);
1;
my $ul = UserList->parse($json);
$ul->send_mail_to_all;
I HATE working with JSON
complex datastructures
(that convey object-ish things)
And JSON
Because this… is not valid JSON 
{ “users”: [
{ “name”: “Joe” },
{ “name”: “Katy” },
]}
Because this… is not valid JSON 
{ “users”: [
{ “name”: “Joe” },
{ “name”: “Katy” },
]}
Trailing comma is a syntax error 
GitHub
http://github.com/pplu/moosex-datamodel
Join me if you have the same pain
Note: highly experimental code. Not released on CPAN until it looks a
bit decent
Thanks!

More Related Content

What's hot

FormValidator::LazyWay で検証ルールをまとめよう
FormValidator::LazyWay で検証ルールをまとめようFormValidator::LazyWay で検証ルールをまとめよう
FormValidator::LazyWay で検証ルールをまとめよう
Daisuke Komatsu
 
Couchdb
CouchdbCouchdb
Couchdb
Brian Smith
 
Topological indices (t is) of the graphs to seek qsar models of proteins com...
Topological indices (t is) of the graphs  to seek qsar models of proteins com...Topological indices (t is) of the graphs  to seek qsar models of proteins com...
Topological indices (t is) of the graphs to seek qsar models of proteins com...
Jitendra Kumar Gupta
 
Embedding a language into string interpolator
Embedding a language into string interpolatorEmbedding a language into string interpolator
Embedding a language into string interpolator
Michael Limansky
 
Being Google
Being GoogleBeing Google
Being Google
Tom Dyson
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
Adib Mehedi
 
C# 3.5 Features
C# 3.5 FeaturesC# 3.5 Features
Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*
Timur Safin
 
Php database connectivity
Php database connectivityPhp database connectivity
Persistencia de datos con Parse
Persistencia de datos con ParsePersistencia de datos con Parse
Persistencia de datos con Parse
Alfonso Alba
 
How Much Immutability Is Enough?
How Much Immutability Is Enough?How Much Immutability Is Enough?
How Much Immutability Is Enough?
Yegor Bugayenko
 
ABV_fastcontact
ABV_fastcontactABV_fastcontact
ABV_fastcontactarjun rao
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Groupkchodorow
 
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentationsupporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
Mahabubur Rahaman
 
Xpath & xquery
Xpath & xqueryXpath & xquery
Xpath & xquery
Meghavi patel
 
Swift & JSON
Swift & JSONSwift & JSON
Swift & JSON
John Sundell
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2Takahiro Inoue
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)MongoSF
 

What's hot (20)

FormValidator::LazyWay で検証ルールをまとめよう
FormValidator::LazyWay で検証ルールをまとめようFormValidator::LazyWay で検証ルールをまとめよう
FormValidator::LazyWay で検証ルールをまとめよう
 
Couchdb
CouchdbCouchdb
Couchdb
 
Topological indices (t is) of the graphs to seek qsar models of proteins com...
Topological indices (t is) of the graphs  to seek qsar models of proteins com...Topological indices (t is) of the graphs  to seek qsar models of proteins com...
Topological indices (t is) of the graphs to seek qsar models of proteins com...
 
Embedding a language into string interpolator
Embedding a language into string interpolatorEmbedding a language into string interpolator
Embedding a language into string interpolator
 
Being Google
Being GoogleBeing Google
Being Google
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
 
C# 3.5 Features
C# 3.5 FeaturesC# 3.5 Features
C# 3.5 Features
 
Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*Native json in the Cache' ObjectScript 2016.*
Native json in the Cache' ObjectScript 2016.*
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Persistencia de datos con Parse
Persistencia de datos con ParsePersistencia de datos con Parse
Persistencia de datos con Parse
 
How Much Immutability Is Enough?
How Much Immutability Is Enough?How Much Immutability Is Enough?
How Much Immutability Is Enough?
 
ABV_fastcontact
ABV_fastcontactABV_fastcontact
ABV_fastcontact
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentationsupporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
supporting t-sql scripts for IndexPage, Datapage and IndexDefragmentation
 
Xpath & xquery
Xpath & xqueryXpath & xquery
Xpath & xquery
 
Swift & JSON
Swift & JSONSwift & JSON
Swift & JSON
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
 
Underscore
UnderscoreUnderscore
Underscore
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
 

Viewers also liked

Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015
Jose Luis Martínez
 
Perl and AWS
Perl and AWSPerl and AWS
Perl and AWS
Jose Luis Martínez
 
Paws - A Perl AWS SDK
Paws - A Perl AWS SDKPaws - A Perl AWS SDK
Paws - A Perl AWS SDK
Jose Luis Martínez
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
Jose Luis Martínez
 
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Writing plugins for Nagios and Opsview - CAPSiDE Tech TalksWriting plugins for Nagios and Opsview - CAPSiDE Tech Talks
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Jose Luis Martínez
 
Boosting MySQL (for starters)
Boosting MySQL (for starters)Boosting MySQL (for starters)
Boosting MySQL (for starters)
Jose Luis Martínez
 
Plenv and carton
Plenv and cartonPlenv and carton
Plenv and carton
Jose Luis Martínez
 
Sophiie compu
Sophiie compuSophiie compu
Sophiie compu
Sophiie Mendoza
 
Infinity
InfinityInfinity
Infinityjs229
 
Questionnaire results
Questionnaire resultsQuestionnaire results
Questionnaire resultskamar95
 
Kutner and olsen
Kutner and olsenKutner and olsen
Kutner and olsen
kamar95
 
θουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμαθουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμα
Efi Manousaka
 
Pictures i have used in my magazine 2
Pictures i have used in my magazine 2Pictures i have used in my magazine 2
Pictures i have used in my magazine 2kamar95
 
How to use photoshop
How to use photoshopHow to use photoshop
How to use photoshop
kamar95
 
Feedback from the first versions of my music
Feedback from the first versions of my musicFeedback from the first versions of my music
Feedback from the first versions of my musickamar95
 
Daniel & Ernesto's presentation
Daniel & Ernesto's presentationDaniel & Ernesto's presentation
Daniel & Ernesto's presentationErnesto Sepulveda
 
My fist drafts presnetation
My fist drafts presnetationMy fist drafts presnetation
My fist drafts presnetationkamar95
 
Bloedsomloop versie 1.0
Bloedsomloop versie 1.0Bloedsomloop versie 1.0
Bloedsomloop versie 1.0
RIBW Arnhem & Veluwe Vallei
 
DBIx::Class
DBIx::ClassDBIx::Class
DBIx::Class
Jose Luis Martínez
 

Viewers also liked (20)

Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015
 
Perl and AWS
Perl and AWSPerl and AWS
Perl and AWS
 
Paws - A Perl AWS SDK
Paws - A Perl AWS SDKPaws - A Perl AWS SDK
Paws - A Perl AWS SDK
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
 
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Writing plugins for Nagios and Opsview - CAPSiDE Tech TalksWriting plugins for Nagios and Opsview - CAPSiDE Tech Talks
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
 
Boosting MySQL (for starters)
Boosting MySQL (for starters)Boosting MySQL (for starters)
Boosting MySQL (for starters)
 
Plenv and carton
Plenv and cartonPlenv and carton
Plenv and carton
 
Sophiie compu
Sophiie compuSophiie compu
Sophiie compu
 
Arxaia b gymn
Arxaia b gymnArxaia b gymn
Arxaia b gymn
 
Infinity
InfinityInfinity
Infinity
 
Questionnaire results
Questionnaire resultsQuestionnaire results
Questionnaire results
 
Kutner and olsen
Kutner and olsenKutner and olsen
Kutner and olsen
 
θουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμαθουκυδίδου ι αγνωστο θεμα
θουκυδίδου ι αγνωστο θεμα
 
Pictures i have used in my magazine 2
Pictures i have used in my magazine 2Pictures i have used in my magazine 2
Pictures i have used in my magazine 2
 
How to use photoshop
How to use photoshopHow to use photoshop
How to use photoshop
 
Feedback from the first versions of my music
Feedback from the first versions of my musicFeedback from the first versions of my music
Feedback from the first versions of my music
 
Daniel & Ernesto's presentation
Daniel & Ernesto's presentationDaniel & Ernesto's presentation
Daniel & Ernesto's presentation
 
My fist drafts presnetation
My fist drafts presnetationMy fist drafts presnetation
My fist drafts presnetation
 
Bloedsomloop versie 1.0
Bloedsomloop versie 1.0Bloedsomloop versie 1.0
Bloedsomloop versie 1.0
 
DBIx::Class
DBIx::ClassDBIx::Class
DBIx::Class
 

Similar to MooseX::Datamodel - Barcelona Perl Workshop Lightning talk

BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7
Georgi Kodinov
 
Functional es6
Functional es6Functional es6
Functional es6
Natalia Zaslavskaya
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
Saeid Zebardast
 
My sql presentation
My sql presentationMy sql presentation
My sql presentationNikhil Jain
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivityMouli Chandira
 
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...
Педагошко друштво информатичара Србије
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
Nate Abele
 
Protocol Oriented JSON Parsing in Swift
Protocol Oriented JSON Parsing in SwiftProtocol Oriented JSON Parsing in Swift
Protocol Oriented JSON Parsing in Swift
Jason Larsen
 
Test du futur avec Spock
Test du futur avec SpockTest du futur avec Spock
Test du futur avec Spock
CARA_Lyon
 
JSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureJSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger picture
Sergey Petrunya
 
Groovy
GroovyGroovy
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
Tomas Jansson
 
MYSQL
MYSQLMYSQL
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
syeda zoya mehdi
 
Angular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmidAngular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmid
Amrita Chopra
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Rifat Nabi
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2
Adam Klein
 
Laravel
LaravelLaravel
Laravel
Sayed Ahmed
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)Raghu nath
 

Similar to MooseX::Datamodel - Barcelona Perl Workshop Lightning talk (20)

BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7BGOUG15: JSON support in MySQL 5.7
BGOUG15: JSON support in MySQL 5.7
 
Functional es6
Functional es6Functional es6
Functional es6
 
Developing Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginnersDeveloping Applications with MySQL and Java for beginners
Developing Applications with MySQL and Java for beginners
 
My sql presentation
My sql presentationMy sql presentation
My sql presentation
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...
FNT 2015 PDIS CodeEU - Zanimljiva informatika - 02 Djordje Pavlovic - Live_ch...
 
The State of Lithium
The State of LithiumThe State of Lithium
The State of Lithium
 
Protocol Oriented JSON Parsing in Swift
Protocol Oriented JSON Parsing in SwiftProtocol Oriented JSON Parsing in Swift
Protocol Oriented JSON Parsing in Swift
 
Test du futur avec Spock
Test du futur avec SpockTest du futur avec Spock
Test du futur avec Spock
 
Week 12 code
Week 12 codeWeek 12 code
Week 12 code
 
JSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger pictureJSON Support in MariaDB: News, non-news and the bigger picture
JSON Support in MariaDB: News, non-news and the bigger picture
 
Groovy
GroovyGroovy
Groovy
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
MYSQL
MYSQLMYSQL
MYSQL
 
Php update and delet operation
Php update and delet operationPhp update and delet operation
Php update and delet operation
 
Angular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmidAngular 2 Component Communication - Talk by Rob McDiarmid
Angular 2 Component Communication - Talk by Rob McDiarmid
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Data models in Angular 1 & 2
Data models in Angular 1 & 2Data models in Angular 1 & 2
Data models in Angular 1 & 2
 
Laravel
LaravelLaravel
Laravel
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 

More from Jose Luis Martínez

Being cloudy with perl
Being cloudy with perlBeing cloudy with perl
Being cloudy with perl
Jose Luis Martínez
 
Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)
Jose Luis Martínez
 
Escribir plugins para Nagios en Perl
Escribir plugins para Nagios en PerlEscribir plugins para Nagios en Perl
Escribir plugins para Nagios en Perl
Jose Luis Martínez
 
NRD: Nagios Result Distributor
NRD: Nagios Result DistributorNRD: Nagios Result Distributor
NRD: Nagios Result Distributor
Jose Luis Martínez
 
Writing nagios plugins in perl
Writing nagios plugins in perlWriting nagios plugins in perl
Writing nagios plugins in perl
Jose Luis Martínez
 
Ficheros y directorios
Ficheros y directoriosFicheros y directorios
Ficheros y directorios
Jose Luis Martínez
 
DBI
DBIDBI
The modern perl toolchain
The modern perl toolchainThe modern perl toolchain
The modern perl toolchain
Jose Luis Martínez
 
Introducción a las Expresiones Regulares
Introducción a las Expresiones RegularesIntroducción a las Expresiones Regulares
Introducción a las Expresiones Regulares
Jose Luis Martínez
 

More from Jose Luis Martínez (9)

Being cloudy with perl
Being cloudy with perlBeing cloudy with perl
Being cloudy with perl
 
Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)Modern Perl toolchain (help building microservices)
Modern Perl toolchain (help building microservices)
 
Escribir plugins para Nagios en Perl
Escribir plugins para Nagios en PerlEscribir plugins para Nagios en Perl
Escribir plugins para Nagios en Perl
 
NRD: Nagios Result Distributor
NRD: Nagios Result DistributorNRD: Nagios Result Distributor
NRD: Nagios Result Distributor
 
Writing nagios plugins in perl
Writing nagios plugins in perlWriting nagios plugins in perl
Writing nagios plugins in perl
 
Ficheros y directorios
Ficheros y directoriosFicheros y directorios
Ficheros y directorios
 
DBI
DBIDBI
DBI
 
The modern perl toolchain
The modern perl toolchainThe modern perl toolchain
The modern perl toolchain
 
Introducción a las Expresiones Regulares
Introducción a las Expresiones RegularesIntroducción a las Expresiones Regulares
Introducción a las Expresiones Regulares
 

Recently uploaded

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 

Recently uploaded (20)

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 

MooseX::Datamodel - Barcelona Perl Workshop Lightning talk

  • 1. Hi!
  • 3. { “users”: [ { “name”: “Joe” }, { “name”: “Katy” }, ]}
  • 4. {“users”:[{ “name”:“Joe” },{ “name”:“Katy” }]}
  • 5. my $var = { users => [ { name => ‘Joe’ }, { name => ‘Katy’ }, ] }; foreach my $user @{ $var->{ users } } { … } Parsing JSON gives you this Access to the data is like this
  • 6. Working with complex datastructures:
  • 7. { users => [ { name => ‘Joe’ }, { name => ‘Katy’ }, ] } USERLIST USER
  • 9. Why not express the structure like this? package UserList; use MooseX::DataModel; array users (isa => ‘User’); 1; package User; use MooseX::DataModel; key name => (isa => ‘Str’, required => 1); 1; my $ul =UserList->parse($json); say $ul->users->[0]->name; This even validates the JSON to the schema!
  • 10. We can even tack methods on the objects! package UserList; use MooseX::DataModel; array users (isa => ‘User’); sub send_mail_to_all { … for ($self->users) { … } … }; 1; package User; key name => (isa => ‘Str’, required => 1); 1; my $ul = UserList->parse($json); $ul->send_mail_to_all;
  • 11. I HATE working with JSON complex datastructures (that convey object-ish things)
  • 13. Because this… is not valid JSON  { “users”: [ { “name”: “Joe” }, { “name”: “Katy” }, ]}
  • 14. Because this… is not valid JSON  { “users”: [ { “name”: “Joe” }, { “name”: “Katy” }, ]} Trailing comma is a syntax error 
  • 15. GitHub http://github.com/pplu/moosex-datamodel Join me if you have the same pain Note: highly experimental code. Not released on CPAN until it looks a bit decent