SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
hnyb1002
 
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
 

Mais procurados (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
 
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
 
PHP Tutorial (funtion)
PHP Tutorial (funtion)PHP Tutorial (funtion)
PHP Tutorial (funtion)
 
PHP 1
PHP 1PHP 1
PHP 1
 
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
 
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
 
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
 
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
 
php plus mysql
php plus mysqlphp plus mysql
php plus mysql
 
Aggregation in MongoDB
Aggregation in MongoDBAggregation in MongoDB
Aggregation in MongoDB
 
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
 
Embedding a language into string interpolator
Embedding a language into string interpolatorEmbedding a language into string interpolator
Embedding a language into string interpolator
 
Php code for online quiz
Php code for online quizPhp code for online quiz
Php code for online quiz
 
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
 
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
 
Threading
ThreadingThreading
Threading
 
Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB Introduction à CoffeeScript pour ParisRB
Introduction à CoffeeScript pour ParisRB
 
Object Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHPObject Calisthenics Adapted for PHP
Object Calisthenics Adapted for PHP
 
Inc
IncInc
Inc
 
Php
PhpPhp
Php
 

Semelhante a Native json in the Cache' ObjectScript 2016.*

Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
Taras Kalapun
 
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
 

Semelhante a 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
 
Gson
GsonGson
Gson
 
Processing & Dataviz
Processing & DatavizProcessing & Dataviz
Processing & Dataviz
 
Conquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQLConquering JSONB in PostgreSQL
Conquering JSONB in PostgreSQL
 
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
 
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
Swift - 혼자 공부하면 분명히 안할테니까 같이 공부하기
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
 
Everyday's JS
Everyday's JSEveryday's JS
Everyday's JS
 
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
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
Json
JsonJson
Json
 
Crazy things done on PHP
Crazy things done on PHPCrazy things done on PHP
Crazy things done on PHP
 
PyLecture3 -json-
PyLecture3 -json-PyLecture3 -json-
PyLecture3 -json-
 
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
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
SetFocus Portfolio
SetFocus PortfolioSetFocus Portfolio
SetFocus Portfolio
 
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
 
Swift & JSON
Swift & JSONSwift & JSON
Swift & JSON
 
Data Representation - Day 2
Data Representation - Day 2Data Representation - Day 2
Data Representation - Day 2
 

Mais de Timur Safin

Mais de Timur Safin (8)

Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶ отладки в Tarantool
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶  отладки в TarantoolИнструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶  отладки в Tarantool
Инструменты для з̶а̶х̶в̶а̶т̶а̶ ̶м̶и̶р̶а̶ отладки в Tarantool
 
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
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
 
InterSystems iKnow and Twitter API
InterSystems iKnow and Twitter APIInterSystems iKnow and Twitter API
InterSystems iKnow and Twitter API
 
Multimodel Database Caché
Multimodel Database CachéMultimodel Database Caché
Multimodel Database Caché
 
Implementation of community package manager
Implementation of community package managerImplementation of community package manager
Implementation of community package manager
 
Новости Global summit 2015
Новости Global summit 2015Новости Global summit 2015
Новости Global summit 2015
 
Approaching package manager
Approaching package managerApproaching package manager
Approaching package manager
 

Último

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

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