Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
a06908d2
Commit
a06908d2
authored
9 years ago
by
ocelot-inc
Browse files
Options
Downloads
Patches
Plain Diff
gh-963 serializer is not documented
parent
28908a51
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/sphinx/book/box/box_index.rst
+1
-1
1 addition, 1 deletion
doc/sphinx/book/box/box_index.rst
doc/sphinx/reference/json.rst
+9
-0
9 additions, 0 deletions
doc/sphinx/reference/json.rst
doc/sphinx/reference/yaml.rst
+40
-22
40 additions, 22 deletions
doc/sphinx/reference/yaml.rst
with
50 additions
and
23 deletions
doc/sphinx/book/box/box_index.rst
+
1
−
1
View file @
a06908d2
...
@@ -663,7 +663,7 @@ is Rectangle#2", and "Rectangle#3 is entirely inside Rectangle#2".
...
@@ -663,7 +663,7 @@ is Rectangle#2", and "Rectangle#3 is entirely inside Rectangle#2".
Now let us create a space and add an RTREE index.
Now let us create a space and add an RTREE index.
| :codebold:`s = box.schema.
create_spac
e('rectangles')`
| :codebold:`s = box.schema.
space.creat
e('rectangles')`
| :codebold:`i = s:create_index('primary',{type='HASH',parts={1,'NUM'}})`
| :codebold:`i = s:create_index('primary',{type='HASH',parts={1,'NUM'}})`
| :codebold:`r = s:create_index('spatial',{type='RTREE',unique=false,parts={2,'ARRAY'}})`
| :codebold:`r = s:create_index('spatial',{type='RTREE',unique=false,parts={2,'ARRAY'}})`
...
...
This diff is collapsed.
Click to expand it.
doc/sphinx/reference/json.rst
+
9
−
0
View file @
a06908d2
...
@@ -95,5 +95,14 @@ The json package provides JSON manipulation routines. It is based on the
...
@@ -95,5 +95,14 @@ The json package provides JSON manipulation routines. It is based on the
| :codenormal:`- '{"field2":null,"field1":"a","field3":"c"}'`
| :codenormal:`- '{"field2":null,"field1":"a","field3":"c"}'`
| :codenormal:`...`
| :codenormal:`...`
The JSON output structure can be specified with :code:`__serialize`:
__serialize="seq" for an array,
__serialize="map" for a map.
Serializing 'A' and 'B' with different __serialize values causes different results: |br|
:codebold:`json.encode(setmetatable({'A', 'B'}, { __serialize="seq"}))` |br|
:codenormal:`- '["A","B"]'` |br|
:codebold:`json.encode({setmetatable({f1 = 'A', f2 = 'B'}, { __serialize="map"})})` |br|
:codenormal:`- '[{"f2":"B","f1":"A"}]'` |br|
.. _Lua-CJSON package by Mark Pulford: http://www.kyne.com.au/~mark/software/lua-cjson.php
.. _Lua-CJSON package by Mark Pulford: http://www.kyne.com.au/~mark/software/lua-cjson.php
.. _the official documentation: http://www.kyne.com.au/~mark/software/lua-cjson-manual.html
.. _the official documentation: http://www.kyne.com.au/~mark/software/lua-cjson-manual.html
This diff is collapsed.
Click to expand it.
doc/sphinx/reference/yaml.rst
+
40
−
22
View file @
a06908d2
...
@@ -33,27 +33,45 @@ series of non-YAML values and encodes them.
...
@@ -33,27 +33,45 @@ series of non-YAML values and encodes them.
Example
Example
=================================================
=================================================
.. code-block:: lua
| :codenormal:`tarantool>` :codebold:`yaml = require('yaml')`
| :codenormal:`---`
tarantool> yaml = require('yaml')
| :codenormal:`...`
---
| :codenormal:`tarantool>` :codebold:`y = yaml.encode({'a',1,'b',2})`
...
| :codenormal:`---`
tarantool> y = yaml.encode({'a',1,'b',2})
| :codenormal:`...`
---
| :codenormal:`tarantool>` :codebold:`z = yaml.decode(y)`
...
| :codenormal:`---`
tarantool> z = yaml.decode(y)
| :codenormal:`...`
---
| :codenormal:`tarantool>` :codebold:`z[1],z[2],z[3],z[4]`
...
| :codenormal:`---`
tarantool> z[1],z[2],z[3],z[4]
| :codenormal:`- a`
---
| :codenormal:`- 1`
- a
| :codenormal:`- b`
- 1
| :codenormal:`- 2`
- b
| :codenormal:`...`
- 2
| :codenormal:`tarantool>` :codebold:`if yaml.NULL == nil then print('hi') end`
...
| :codenormal:`hi`
tarantool> if yaml.NULL == nil then print('hi') end
| :codenormal:`---`
hi
| :codenormal:`...`
---
...
The `YAML collection style <http://yaml.org/spec/1.1/#id930798>`_ can be specified with :code:`__serialize`:
__serialize="sequence" for a Block Sequence array,
__serialize="seq" for a Flow Sequence array,
__serialize="mapping" for a Block Mapping map,
__serialize="map" for a Flow Mapping map.
Serializing 'A' and 'B' with different __serialize values causes different results: |br|
:codebold:`yaml.encode(setmetatable({'A', 'B'}, { __serialize="sequence"}))` |br|
:codenormal:`- A` |br|
:codenormal:`- B` |br|
:codebold:`yaml.encode(setmetatable({'A', 'B'}, { __serialize="seq"}))` |br|
:codenormal:`- ['A', 'B']` |br|
:codebold:`yaml.encode({setmetatable({f1 = 'A', f2 = 'B'}, { __serialize="map"})})` |br|
:codenormal:`- f2: B` |br|
:codenormal:`- f1: A` |br|
:codebold:`yaml.encode({setmetatable({f1 = 'A', f2 = 'B'}, { __serialize="mapping"})})` |br|
:codenormal:`- {'f2': 'B', 'f1': 'A'}` |br|
.. _YAML: http://yaml.org/
.. _YAML: http://yaml.org/
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment