summaryrefslogtreecommitdiffstats
path: root/DOCS
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-19 05:27:35 +0200
committerwm4 <wm4@nowhere>2014-10-19 05:51:37 +0200
commit5548c75e5507da6a0f9fb6a45a07a5cc6edd9393 (patch)
treeabd1a7442abf056900a518ffa6bfe3606f1329cc /DOCS
parent987146362e35820cd96d7de4f48b13ec4ee25d7c (diff)
downloadmpv-5548c75e5507da6a0f9fb6a45a07a5cc6edd9393.tar.bz2
mpv-5548c75e5507da6a0f9fb6a45a07a5cc6edd9393.tar.xz
lua: expose JSON parser
The JSON parser was introduced for the IPC protocol, but I guess it's useful here too. The motivation for this commit is the same as with 8e4fa5fc (again).
Diffstat (limited to 'DOCS')
-rw-r--r--DOCS/man/lua.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst
index c49d2c388c..2eddbb8f2f 100644
--- a/DOCS/man/lua.rst
+++ b/DOCS/man/lua.rst
@@ -593,6 +593,20 @@ strictly part of the guaranteed API.
In all cases, ``mp.resume_all()`` is implicitly called.
+``utils.parse_json(str [, trail])``
+ Parses the given string argument as JSON, and returns it as a Lua table. On
+ error, returns ``nil, error``. (Currently, ``error`` is just a string
+ reading ``error``, because there is no fine-grained error reporting of any
+ kind.)
+
+ The returned value uses similar conventions as ``mp.get_property_native()``
+ to distinguish empty objects and arrays.
+
+ If the ``trail`` parameter is ``true`` (or any value equal to ``true``),
+ then trailing non-whitespace text is tolerated by the function, and the
+ trailing text is returned as 3rd return value. (The 3rd return value is
+ always there, but with ``trail`` set, no error is raised.)
+
Events
------