SlideShare a Scribd company logo
Native JSON в
Caché ObjectScript
Тимур Сафин
Синтаксис JSON
0
“string”
true
false
null
“key” : “value”
{}
[]
Это – JSON
{"firstName":"John", "lastName":"Doe"}
Это – JSON
"employees“ : [
{"firstName” : "John", "lastName“ : "Doe"},
{"firstName“ : "Anna", "lastName“ : "Smith"},
{"firstName“ : "Peter", "lastName“ : "Jones"}
]
Это – не совсем JSON
SELECT '[1, 2, "foo", null]'::json;
SELECT '{"bar": "baz", "balance": 7.77, "active": false}'::json;
SELECT '{"foo": [true, "bar"], "tags": {"a": 1, "b": null}}'::json;
%Object и %Array
USER>set object = ##class(%Object).$new()
USER>set object.name = "Stefan Wittmann"
USER>set object.lastSeriesSeen = "Daredevil"
USER>set object.likes = "Galaxy"
%Object и %Array
USER>set array = ##class(%Array).$new()
USER>do array.$push(1)
USER>do array.$push("This is a string")
USER>do array.$push(object)
Сериализация в JSON
USER>do object.$toJSON()
{"name":"Stefan Wittmann","lastSeriesSeen":"Daredevil",
"likes":"Galaxy"}
USER>do array.$toJSON()
[1,"This is a string.",{"name":"Stefan Wittmann",
"lastSeriesSeen":"Daredevil","likes":"Galaxy"}]
Разбор JSON
USER>set someJSONstring = "{""firstname"":""Stefan"",
""lastname"":""Wittmann""}"
USER>set consumedJSON = ##class(%AbstractObject).
$fromJSON(someJSONstring)
USER>write consumedJSON.$size()
2
USER>write consumedJSON.$toJSON()
{"firstname":"Stefan","lastname":"Wittmann"}
Итераторы на %Object
USER>set iter = object.$getIterator()
USER>while iter.$getNext(.key,.value) {
write "key "_key_" : "_value,! }
key name : Stefan Wittmann
key lastSeriesSeen : Daredevil
key likes : Galaxy
Итераторы на %Array
USER>set iter = array.$getIterator()
USER>while iter.$getNext(.key,.value) {
write "key "_key_" : "_value,! }
key 0 : 1
key 1 : This is a string.
key 2 : 2@%Library.Object
Присваивание элемента в %Array
USER>do array.$set(10,
"This is a string in a sparse array")
USER>write array.$toJSON()
[1,"This is a string.",{"name":"Stefan Wittmann",
"lastSeriesSeen":"Daredevil","likes":"Galaxy"},
null,null,null,null,null,null,null,
"This is a string in a sparse array"]
Итератор по разреженному массиву
USER>set iter = array.$getIterator()
USER>while iter.$getNext(.key,.value) {
write "key "_key_" : "_value,! }
key 0 : 1
key 1 : This is a string.
key 2 : 2@%Library.Object
key 10 : This is a string in a sparse array
Native JSON Syntax
USER>set object = {"name":"Stefan Wittmann",
"lastMovieSeen":"The Martian",
"likes":"Writing Blogs"}
USER>write object.$toJSON()
{"name":"Stefan Wittmann","lastMovieSeen":
"The Martian","likes":"Writing Blogs"}
USER>set array = [1,2,3,[4,5,6],true,false,null]
USER>write array.$toJSON()
[1,2,3,[4,5,6],true,false,null]
Native JSON Syntax
USER>set object = {}
USER>set array = []
Native JSON Syntax
USER>set name = "Stefan"
USER>set subObject = {"nationality":"German",
"favoriteColors":["yellow","blue"]}
USER>set object = {"name":name,"details":subObject,
"lastUpdate":$ZD($H,3)}
USER>write object.$toJSON()
{"name":"Stefan","details":{"nationality":"German",
"favoriteColors":["yellow","blue"]}," lastUpdate ":
"2016-01-31"}
Native JSON Syntax
USER>set array = [1,2,3,[4,5,6],true,false,null]
USER>set iter = array.$getIterator()
USER>while iter.$getNext(.key,.value) {
write "key "_key_":"_value,! }
key 0:1
key 1:2
key 2:3
key 3:5@%Library.Array
key 4:1
key 5:0
key 6:
Native JSON Syntax
USER>set array = [1,2,3,[4,5,6],true,false,null]
…
USER>w array.$getTypeOf(5)
boolean
USER>w array.$getTypeOf(6)
null
Native JSON Syntax
USER>set array = [1,2,3,[4,5,6],true,false,null]
…
USER>do array.$set(7,1)
USER>write array.$toJSON()
[1,2,3,[4,5,6],true,false,null,1]
USER>do array.$set(7,1,"boolean")
USER>write array.$toJSON()
[1,2,3,[4,5,6],true,false,null,true]
Системные методы
$new
$set
$push
$pop
$size
$compose
$compose
SAMPLES>set object = array.$compose("%Object")
SAMPLES>write ["zero","one","two"].
$compose("%Object").$toJSON()
{"0":"zero","1":"one","2":"two"}
$compose
SAMPLES>set person = ##class(Sample.Person).%OpenId(10)
SAMPLES>set object = person.$compose("%Object")
SAMPLES>write object.$toJSON()
{"$CLASSNAME":"Sample.Person","$REFERENCE":"10",
"Age":46,"DOB":47058,"FavoriteColors":[],
"Home":{"City":"Washington","State":"HI","Street":
"4358 Franklin Place","Zip":59519},"Name":"Quincy,Neil Z.",
"Office":{"City":"Bensonhurst","State":"WI","Street":
"8620 Clinton Drive","Zip":75074},"SSN":"966-11-9404"}
Result Sets
SAMPLES>set result = $system.SQL.Execute("call sample.sp_sample_by_name('N')").
%NextResult()
SAMPLES>write result.$toJSON()
{"content":[{"DOB":"63986","ID":"189","Name":"Nathanson,Natasha T.","SSN":
"439-13-7455"},{"DOB":"58420","ID":"85","Name":"Nelson,Charlotte Y.",
"SSN":"664-42-8486"},{"DOB":"34965","ID":"150","Name":"Noodleman,Charles Y.",
"SSN":"156-64-3875"},{"DOB":"39300","ID":"134","Name":"North,Ted J.",
"SSN":"308-14-4306"}],"metadata":{"columnCount":4,"columns":
[{"ODBCType":4,"clientType":"","colName":"ID","isAliased":1,"isAutoIncrement":1,
"isCaseSensitive":1,"isCurrency":0,"isExpression":0,"isHidden":0,"isIdentity":1,
"isKeyColumn":1,"isNullable":0,"isReadOnly":1,"isRowId":1,"isRowVersion":0,
"isUnique":1,"label":"ID","precision":10,"qualifier":"","scale":0,"schemaName":
"Sample","tableName":"Person"},{"ODBCType":12,"clientType":"","colName":"Name",
"isAliased":1,"isAutoIncrement":0,"isCaseSensitive":0,"isCurrency":0,
"isExpression":0,"isHidden":0,"isIdentity":0,"isKeyColumn":0,"isNullable":0,
"isReadOnly":0,"isRowId":0,"isRowVersion":0,"isUnique":0,"label":"Name",
"precision":50,"qualifier":"","scale":0…
И это мы еще не
рассказали про JSON
расширения в SQL…
JSON & SQL
LATEST:USER>set response = ##class(%Net.Http).getJSON(
"http://localhost:57772/api/document/v1/SAMPLES/continents",
{"Username":"_SYSTEM","Password":"SYS"})
LATEST:USER>do response.$toJSON()
{"collection":"continents","size":8,"content":[{"documentID":1,
"documentVersion":1,"content":{"code":"NA","name":"North America"}},
{"documentID":2,"documentVersion":2,"content":{"code":"SA","name":
"South America"}},{"documentID":3,"documentVersion":3,"content":{"code":
"AF","name":"Africa"}},{"documentID":4,"documentVersion":4,"content":
{"code":"AS","name":"Asia"}},{"documentID":5,"documentVersion":5,
"content":{"code":"EU","name":"Europe"}},{"documentID":6,"documentVersion":6,
"content":{"code":"OC","name":"Oceana"}},{"documentID":7,"documentVersion":7,
"content":{"code":"AN","name":"Antarctica"}},{"documentID":9,"documentVersion":8,
"content":{}}]}
JSON & SQL
select code, name from JSON_TABLE(%Net.getJSON(
'http://localhost/api/document/v1/SAMPLES/continents',
'{"Username":"_SYSTEM","Password":"SYS","Port":57772}'),
'$.content' columns (document varchar(2000) path '$',
code varchar(2) path '$.content.code',
name varchar(50) path '$.content.name')) order by name
Производительность
Производительность разбора JSON
(Each company has an average of 20
employees and 20 customers each with several
addresses)
Caché 2015.1
zenProxyObject
Caché 2016.*
Native JSON
NodeJS
0.12.2
v8: 3.28.73
Load 1000 companies JSON file
(10.8MB)
28000ms 94ms 97ms
Find how many employees called
"Robert“ (126 employees)
55ms 55ms 2ms
Load 10,000 companies JSON file
(108MB)
386700ms 904ms 892ms
Find how many employees called
"Robert" (1346 employees)
554.5ms 567ms 13ms
Ad

More Related Content

What's hot (20)

Modern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter BootstrapModern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter Bootstrap
Howard Lewis Ship
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
Jeremy Kendall
 
PHP Tutorial (funtion)
PHP Tutorial (funtion)PHP Tutorial (funtion)
PHP Tutorial (funtion)
Tinnakorn Puttha
 
PHP 1
PHP 1PHP 1
PHP 1
Mohammed Abutabikh
 
Kotlin: Let's Make Android Great Again
Kotlin: Let's Make Android Great AgainKotlin: Let's Make Android Great Again
Kotlin: Let's Make Android Great Again
Taeho Kim
 
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
Taeho Kim
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 
php plus mysql
php plus mysqlphp plus mysql
php plus mysql
Jayson de Leon
 
Aggregation in MongoDB
Aggregation in MongoDBAggregation in MongoDB
Aggregation in MongoDB
Kishor Parkhe
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
Rafael Dohms
 
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
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
hnyb1002
 
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right WayMongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
ichikaway
 
Threading
ThreadingThreading
Threading
b290572
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
jhchabran
 
Object Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPObject Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHP
Chad Gray
 
Inc
IncInc
Inc
Lax Sindikat
 
Php
PhpPhp
Php
Linh Tran
 
Modern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter BootstrapModern Application Foundations: Underscore and Twitter Bootstrap
Modern Application Foundations: Underscore and Twitter Bootstrap
Howard Lewis Ship
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
Jeremy Kendall
 
Kotlin: Let's Make Android Great Again
Kotlin: Let's Make Android Great AgainKotlin: Let's Make Android Great Again
Kotlin: Let's Make Android Great Again
Taeho Kim
 
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
Taeho Kim
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
Jeremy Kendall
 
Aggregation in MongoDB
Aggregation in MongoDBAggregation in MongoDB
Aggregation in MongoDB
Kishor Parkhe
 
You code sucks, let's fix it
You code sucks, let's fix itYou code sucks, let's fix it
You code sucks, let's fix it
Rafael Dohms
 
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
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
hnyb1002
 
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right WayMongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB Europe 2016 - ETL for Pros – Getting Data Into MongoDB The Right Way
MongoDB
 
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
Tips of CakePHP and MongoDB - Cakefest2011 ichikaway
ichikaway
 
Threading
ThreadingThreading
Threading
b290572
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
jhchabran
 
Object Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPObject Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHP
Chad Gray
 

Similar to Native json in the Cache' ObjectScript 2016.* (20)

Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
Daniel Blyth
 
Gson
GsonGson
Gson
哲偉 楊
 
Processing & Dataviz
Processing & DatavizProcessing & Dataviz
Processing & Dataviz
blprnt
 
Conquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQLConquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQL
Ines Panker
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's Java
Sven Efftinge
 
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Suyeol Jeon
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
Skillwise Group
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
Adib Mehedi
 
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in KotlinKotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
JetBrains Russia
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
garux
 
Json
JsonJson
Json
Raphael Wanjiku
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
Taras Kalapun
 
PyLecture3 -json-
PyLecture3 -json-PyLecture3 -json-
PyLecture3 -json-
Yoshiki Satotani
 
ddd+scala
ddd+scaladdd+scala
ddd+scala
潤一 加藤
 
4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz
4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz
4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz
PROIDEA
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath
 
SetFocus Portfolio
SetFocus PortfolioSetFocus Portfolio
SetFocus Portfolio
donjoshu
 
Json at work overview and ecosystem-v2.0
Json at work   overview and ecosystem-v2.0Json at work   overview and ecosystem-v2.0
Json at work overview and ecosystem-v2.0
Boulder Java User's Group
 
Swift & JSON
Swift & JSONSwift & JSON
Swift & JSON
John Sundell
 
Data Representation - Day 2
Data Representation - Day 2Data Representation - Day 2
Data Representation - Day 2
blprnt
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
Daniel Blyth
 
Processing & Dataviz
Processing & DatavizProcessing & Dataviz
Processing & Dataviz
blprnt
 
Conquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQLConquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQL
Ines Panker
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's Java
Sven Efftinge
 
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Suyeol Jeon
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
Skillwise Group
 
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in KotlinKotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
Kotlin Programming Language. What it is all about. Roman Belov, PMM in Kotlin
JetBrains Russia
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
garux
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
Taras Kalapun
 
4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz
4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz
4Developers 2015: Testowanie ze Spockiem - Dominik Przybysz
PROIDEA
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath
 
SetFocus Portfolio
SetFocus PortfolioSetFocus Portfolio
SetFocus Portfolio
donjoshu
 
Data Representation - Day 2
Data Representation - Day 2Data Representation - Day 2
Data Representation - Day 2
blprnt
 
Ad

More from Timur Safin (8)

Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶ отладки в Tarantool
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶  отладки в TarantoolИнструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶  отладки в Tarantool
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶ отладки в Tarantool
Timur Safin
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
Timur Safin
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
InterSystems iKnow and Twitter API
InterSystems iKnow and Twitter APIInterSystems iKnow and Twitter API
InterSystems iKnow and Twitter API
Timur Safin
 
Multimodel Database Caché
Multimodel Database CachéMultimodel Database Caché
Multimodel Database Caché
Timur Safin
 
Implementation of community package manager
Implementation of community package managerImplementation of community package manager
Implementation of community package manager
Timur Safin
 
Новости Global summit 2015
Новости Global summit 2015Новости Global summit 2015
Новости Global summit 2015
Timur Safin
 
Approaching package manager
Approaching package managerApproaching package manager
Approaching package manager
Timur Safin
 
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶ отладки в Tarantool
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶  отладки в TarantoolИнструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶  отладки в Tarantool
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶ отладки в Tarantool
Timur Safin
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
Timur Safin
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
InterSystems iKnow and Twitter API
InterSystems iKnow and Twitter APIInterSystems iKnow and Twitter API
InterSystems iKnow and Twitter API
Timur Safin
 
Multimodel Database Caché
Multimodel Database CachéMultimodel Database Caché
Multimodel Database Caché
Timur Safin
 
Implementation of community package manager
Implementation of community package managerImplementation of community package manager
Implementation of community package manager
Timur Safin
 
Новости Global summit 2015
Новости Global summit 2015Новости Global summit 2015
Новости Global summit 2015
Timur Safin
 
Approaching package manager
Approaching package managerApproaching package manager
Approaching package manager
Timur Safin
 
Ad

Recently uploaded (20)

Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game DevelopmentBest Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Juego Studios
 
Implementing promises with typescripts, step by step
Implementing promises with typescripts, step by stepImplementing promises with typescripts, step by step
Implementing promises with typescripts, step by step
Ran Wahle
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025
fs4635986
 
🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf
🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf
🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf
Imma Valls Bernaus
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025
younisnoman75
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game DevelopmentBest Practices for Collaborating with 3D Artists in Mobile Game Development
Best Practices for Collaborating with 3D Artists in Mobile Game Development
Juego Studios
 
Implementing promises with typescripts, step by step
Implementing promises with typescripts, step by stepImplementing promises with typescripts, step by step
Implementing promises with typescripts, step by step
Ran Wahle
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Top 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdfTop 10 Data Cleansing Tools for 2025.pdf
Top 10 Data Cleansing Tools for 2025.pdf
AffinityCore
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
FlakyFix: Using Large Language Models for Predicting Flaky Test Fix Categorie...
Lionel Briand
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Cryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptxCryptocurrency Exchange Script like Binance.pptx
Cryptocurrency Exchange Script like Binance.pptx
riyageorge2024
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025Apple Logic Pro X Crack FRESH Version 2025
Apple Logic Pro X Crack FRESH Version 2025
fs4635986
 
🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf
🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf
🌱 Green Grafana 🌱 Essentials_ Data, Visualizations and Plugins.pdf
Imma Valls Bernaus
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025DVDFab Crack FREE Download Latest Version 2025
DVDFab Crack FREE Download Latest Version 2025
younisnoman75
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 

Native json in the Cache' ObjectScript 2016.*

  • 1. Native JSON в Caché ObjectScript Тимур Сафин
  • 4. Это – JSON "employees“ : [ {"firstName” : "John", "lastName“ : "Doe"}, {"firstName“ : "Anna", "lastName“ : "Smith"}, {"firstName“ : "Peter", "lastName“ : "Jones"} ]
  • 5. Это – не совсем JSON SELECT '[1, 2, "foo", null]'::json; SELECT '{"bar": "baz", "balance": 7.77, "active": false}'::json; SELECT '{"foo": [true, "bar"], "tags": {"a": 1, "b": null}}'::json;
  • 6. %Object и %Array USER>set object = ##class(%Object).$new() USER>set object.name = "Stefan Wittmann" USER>set object.lastSeriesSeen = "Daredevil" USER>set object.likes = "Galaxy"
  • 7. %Object и %Array USER>set array = ##class(%Array).$new() USER>do array.$push(1) USER>do array.$push("This is a string") USER>do array.$push(object)
  • 8. Сериализация в JSON USER>do object.$toJSON() {"name":"Stefan Wittmann","lastSeriesSeen":"Daredevil", "likes":"Galaxy"} USER>do array.$toJSON() [1,"This is a string.",{"name":"Stefan Wittmann", "lastSeriesSeen":"Daredevil","likes":"Galaxy"}]
  • 9. Разбор JSON USER>set someJSONstring = "{""firstname"":""Stefan"", ""lastname"":""Wittmann""}" USER>set consumedJSON = ##class(%AbstractObject). $fromJSON(someJSONstring) USER>write consumedJSON.$size() 2 USER>write consumedJSON.$toJSON() {"firstname":"Stefan","lastname":"Wittmann"}
  • 10. Итераторы на %Object USER>set iter = object.$getIterator() USER>while iter.$getNext(.key,.value) { write "key "_key_" : "_value,! } key name : Stefan Wittmann key lastSeriesSeen : Daredevil key likes : Galaxy
  • 11. Итераторы на %Array USER>set iter = array.$getIterator() USER>while iter.$getNext(.key,.value) { write "key "_key_" : "_value,! } key 0 : 1 key 1 : This is a string. key 2 : 2@%Library.Object
  • 12. Присваивание элемента в %Array USER>do array.$set(10, "This is a string in a sparse array") USER>write array.$toJSON() [1,"This is a string.",{"name":"Stefan Wittmann", "lastSeriesSeen":"Daredevil","likes":"Galaxy"}, null,null,null,null,null,null,null, "This is a string in a sparse array"]
  • 13. Итератор по разреженному массиву USER>set iter = array.$getIterator() USER>while iter.$getNext(.key,.value) { write "key "_key_" : "_value,! } key 0 : 1 key 1 : This is a string. key 2 : 2@%Library.Object key 10 : This is a string in a sparse array
  • 14. Native JSON Syntax USER>set object = {"name":"Stefan Wittmann", "lastMovieSeen":"The Martian", "likes":"Writing Blogs"} USER>write object.$toJSON() {"name":"Stefan Wittmann","lastMovieSeen": "The Martian","likes":"Writing Blogs"} USER>set array = [1,2,3,[4,5,6],true,false,null] USER>write array.$toJSON() [1,2,3,[4,5,6],true,false,null]
  • 15. Native JSON Syntax USER>set object = {} USER>set array = []
  • 16. Native JSON Syntax USER>set name = "Stefan" USER>set subObject = {"nationality":"German", "favoriteColors":["yellow","blue"]} USER>set object = {"name":name,"details":subObject, "lastUpdate":$ZD($H,3)} USER>write object.$toJSON() {"name":"Stefan","details":{"nationality":"German", "favoriteColors":["yellow","blue"]}," lastUpdate ": "2016-01-31"}
  • 17. Native JSON Syntax USER>set array = [1,2,3,[4,5,6],true,false,null] USER>set iter = array.$getIterator() USER>while iter.$getNext(.key,.value) { write "key "_key_":"_value,! } key 0:1 key 1:2 key 2:3 key 3:5@%Library.Array key 4:1 key 5:0 key 6:
  • 18. Native JSON Syntax USER>set array = [1,2,3,[4,5,6],true,false,null] … USER>w array.$getTypeOf(5) boolean USER>w array.$getTypeOf(6) null
  • 19. Native JSON Syntax USER>set array = [1,2,3,[4,5,6],true,false,null] … USER>do array.$set(7,1) USER>write array.$toJSON() [1,2,3,[4,5,6],true,false,null,1] USER>do array.$set(7,1,"boolean") USER>write array.$toJSON() [1,2,3,[4,5,6],true,false,null,true]
  • 21. $compose SAMPLES>set object = array.$compose("%Object") SAMPLES>write ["zero","one","two"]. $compose("%Object").$toJSON() {"0":"zero","1":"one","2":"two"}
  • 22. $compose SAMPLES>set person = ##class(Sample.Person).%OpenId(10) SAMPLES>set object = person.$compose("%Object") SAMPLES>write object.$toJSON() {"$CLASSNAME":"Sample.Person","$REFERENCE":"10", "Age":46,"DOB":47058,"FavoriteColors":[], "Home":{"City":"Washington","State":"HI","Street": "4358 Franklin Place","Zip":59519},"Name":"Quincy,Neil Z.", "Office":{"City":"Bensonhurst","State":"WI","Street": "8620 Clinton Drive","Zip":75074},"SSN":"966-11-9404"}
  • 23. Result Sets SAMPLES>set result = $system.SQL.Execute("call sample.sp_sample_by_name('N')"). %NextResult() SAMPLES>write result.$toJSON() {"content":[{"DOB":"63986","ID":"189","Name":"Nathanson,Natasha T.","SSN": "439-13-7455"},{"DOB":"58420","ID":"85","Name":"Nelson,Charlotte Y.", "SSN":"664-42-8486"},{"DOB":"34965","ID":"150","Name":"Noodleman,Charles Y.", "SSN":"156-64-3875"},{"DOB":"39300","ID":"134","Name":"North,Ted J.", "SSN":"308-14-4306"}],"metadata":{"columnCount":4,"columns": [{"ODBCType":4,"clientType":"","colName":"ID","isAliased":1,"isAutoIncrement":1, "isCaseSensitive":1,"isCurrency":0,"isExpression":0,"isHidden":0,"isIdentity":1, "isKeyColumn":1,"isNullable":0,"isReadOnly":1,"isRowId":1,"isRowVersion":0, "isUnique":1,"label":"ID","precision":10,"qualifier":"","scale":0,"schemaName": "Sample","tableName":"Person"},{"ODBCType":12,"clientType":"","colName":"Name", "isAliased":1,"isAutoIncrement":0,"isCaseSensitive":0,"isCurrency":0, "isExpression":0,"isHidden":0,"isIdentity":0,"isKeyColumn":0,"isNullable":0, "isReadOnly":0,"isRowId":0,"isRowVersion":0,"isUnique":0,"label":"Name", "precision":50,"qualifier":"","scale":0…
  • 24. И это мы еще не рассказали про JSON расширения в SQL…
  • 25. JSON & SQL LATEST:USER>set response = ##class(%Net.Http).getJSON( "http://localhost:57772/api/document/v1/SAMPLES/continents", {"Username":"_SYSTEM","Password":"SYS"}) LATEST:USER>do response.$toJSON() {"collection":"continents","size":8,"content":[{"documentID":1, "documentVersion":1,"content":{"code":"NA","name":"North America"}}, {"documentID":2,"documentVersion":2,"content":{"code":"SA","name": "South America"}},{"documentID":3,"documentVersion":3,"content":{"code": "AF","name":"Africa"}},{"documentID":4,"documentVersion":4,"content": {"code":"AS","name":"Asia"}},{"documentID":5,"documentVersion":5, "content":{"code":"EU","name":"Europe"}},{"documentID":6,"documentVersion":6, "content":{"code":"OC","name":"Oceana"}},{"documentID":7,"documentVersion":7, "content":{"code":"AN","name":"Antarctica"}},{"documentID":9,"documentVersion":8, "content":{}}]}
  • 26. JSON & SQL select code, name from JSON_TABLE(%Net.getJSON( 'http://localhost/api/document/v1/SAMPLES/continents', '{"Username":"_SYSTEM","Password":"SYS","Port":57772}'), '$.content' columns (document varchar(2000) path '$', code varchar(2) path '$.content.code', name varchar(50) path '$.content.name')) order by name
  • 28. Производительность разбора JSON (Each company has an average of 20 employees and 20 customers each with several addresses) Caché 2015.1 zenProxyObject Caché 2016.* Native JSON NodeJS 0.12.2 v8: 3.28.73 Load 1000 companies JSON file (10.8MB) 28000ms 94ms 97ms Find how many employees called "Robert“ (126 employees) 55ms 55ms 2ms Load 10,000 companies JSON file (108MB) 386700ms 904ms 892ms Find how many employees called "Robert" (1346 employees) 554.5ms 567ms 13ms