string.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. string
  2. ------
  3. String operations.
  4. Synopsis
  5. ^^^^^^^^
  6. .. parsed-literal::
  7. `Search and Replace`_
  8. string(`FIND`_ <string> <substring> <out-var> [...])
  9. string(`REPLACE`_ <match-string> <replace-string> <out-var> <input>...)
  10. string(`REGEX MATCH`_ <match-regex> <out-var> <input>...)
  11. string(`REGEX MATCHALL`_ <match-regex> <out-var> <input>...)
  12. string(`REGEX REPLACE`_ <match-regex> <replace-expr> <out-var> <input>...)
  13. `Manipulation`_
  14. string(`APPEND`_ <string-var> [<input>...])
  15. string(`PREPEND`_ <string-var> [<input>...])
  16. string(`CONCAT`_ <out-var> [<input>...])
  17. string(`JOIN`_ <glue> <out-var> [<input>...])
  18. string(`TOLOWER`_ <string> <out-var>)
  19. string(`TOUPPER`_ <string> <out-var>)
  20. string(`LENGTH`_ <string> <out-var>)
  21. string(`SUBSTRING`_ <string> <begin> <length> <out-var>)
  22. string(`STRIP`_ <string> <out-var>)
  23. string(`GENEX_STRIP`_ <string> <out-var>)
  24. string(`REPEAT`_ <string> <count> <out-var>)
  25. string(`REGEX QUOTE`_ <out-var> <input>...)
  26. `Comparison`_
  27. string(`COMPARE`_ <op> <string1> <string2> <out-var>)
  28. `Hashing`_
  29. string(`\<HASH\>`_ <out-var> <input>)
  30. `Generation`_
  31. string(`ASCII`_ <number>... <out-var>)
  32. string(`HEX`_ <string> <out-var>)
  33. string(`CONFIGURE`_ <string> <out-var> [...])
  34. string(`MAKE_C_IDENTIFIER`_ <string> <out-var>)
  35. string(`RANDOM`_ [<option>...] <out-var>)
  36. string(`TIMESTAMP`_ <out-var> [<format string>] [UTC])
  37. string(`UUID`_ <out-var> ...)
  38. `JSON`_
  39. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  40. {`GET <JSON-GET_>`__ | `GET_RAW <JSON-GET-RAW_>`__ | `TYPE <JSON-TYPE_>`__ | `LENGTH <JSON-LENGTH_>`__}
  41. <json-string> [<member|index> ...])
  42. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  43. `REMOVE <JSON-REMOVE_>`__
  44. <json-string> <member|index> [<member|index> ...])
  45. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  46. `MEMBER <JSON-MEMBER_>`__ <json-string>
  47. [<member|index> ...] <index>)
  48. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  49. `SET <JSON-SET_>`__ <json-string>
  50. <member|index> [<member|index> ...] <value>)
  51. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  52. `EQUAL <JSON-EQUAL_>`__ <json-string1> <json-string2>)
  53. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  54. `STRING_ENCODE <STRING-ENCODE_>`__ <string>)
  55. Search and Replace
  56. ^^^^^^^^^^^^^^^^^^
  57. Search and Replace With Plain Strings
  58. """""""""""""""""""""""""""""""""""""
  59. .. signature::
  60. string(FIND <string> <substring> <output_variable> [REVERSE])
  61. Return the position where the given ``<substring>`` was found in
  62. the supplied ``<string>``. If the ``REVERSE`` flag was used, the command
  63. will search for the position of the last occurrence of the specified
  64. ``<substring>``. If the ``<substring>`` is not found, a position of -1 is
  65. returned.
  66. The ``string(FIND)`` subcommand treats all strings as ASCII-only characters.
  67. The index stored in ``<output_variable>`` will also be counted in bytes,
  68. so strings containing multi-byte characters may lead to unexpected results.
  69. .. signature::
  70. string(REPLACE <match_string>
  71. <replace_string> <output_variable>
  72. <input> [<input>...])
  73. Replace all occurrences of ``<match_string>`` in the ``<input>``
  74. with ``<replace_string>`` and store the result in the ``<output_variable>``.
  75. Search and Replace With Regular Expressions
  76. """""""""""""""""""""""""""""""""""""""""""
  77. .. signature::
  78. string(REGEX MATCH <regular_expression>
  79. <output_variable> <input> [<input>...])
  80. Match the ``<regular_expression>`` once and store the match in the
  81. ``<output_variable>``.
  82. All ``<input>`` arguments are concatenated before matching.
  83. Regular expressions are specified in the subsection just below.
  84. .. signature::
  85. string(REGEX MATCHALL <regular_expression>
  86. <output_variable> <input> [<input>...])
  87. Match the ``<regular_expression>`` as many times as possible and store the
  88. matches in the ``<output_variable>`` as a list.
  89. All ``<input>`` arguments are concatenated before matching.
  90. .. signature::
  91. string(REGEX REPLACE <regular_expression>
  92. <replacement_expression> <output_variable>
  93. <input> [<input>...])
  94. Match the ``<regular_expression>`` as many times as possible and substitute
  95. the ``<replacement_expression>`` for the match in the output.
  96. All ``<input>`` arguments are concatenated before matching.
  97. The ``<replacement_expression>`` may refer to parenthesis-delimited
  98. subexpressions of the match using ``\1``, ``\2``, ..., ``\9``. Note that
  99. two backslashes (``\\1``) are required in CMake code to get a backslash
  100. through argument parsing.
  101. .. versionchanged:: 4.1
  102. The ``^`` anchor now matches only at the beginning of the input
  103. string instead of the beginning of each repeated search.
  104. See policy :policy:`CMP0186`.
  105. Zero-length matches are allowed in ``MATCHALL`` and ``REPLACE``.
  106. Previously, they triggered an error.
  107. The replacement expression may contain references to subexpressions that
  108. didn't match anything. Previously, such references triggered an error.
  109. .. _`Regex Specification`:
  110. Regex Specification
  111. """""""""""""""""""
  112. The following characters have special meaning in regular expressions:
  113. ``^``
  114. Matches at beginning of input
  115. ``$``
  116. Matches at end of input
  117. ``.``
  118. Matches any single character
  119. ``\<char>``
  120. Matches the single character specified by ``<char>``. Use this to
  121. match special regex characters, e.g. ``\.`` for a literal ``.``
  122. or ``\\`` for a literal backslash ``\``. Escaping a non-special
  123. character is unnecessary but allowed, e.g. ``\a`` matches ``a``.
  124. ``[ ]``
  125. Matches any character(s) inside the brackets.
  126. To match a literal ``]``, make it the first character, e.g., ``[]ab]``.
  127. ``[^ ]``
  128. Matches any character(s) not inside the brackets.
  129. To not match a literal ``]``, make it the first character, e.g., ``[^]ab]``.
  130. ``-``
  131. Inside brackets, specifies an inclusive range between characters on
  132. either side, e.g., ``[a-f]`` is ``[abcdef]``.
  133. To match a literal ``-`` using brackets, make it the first or the last
  134. character, e.g., ``[+*/-]`` matches basic mathematical operators.
  135. ``*``
  136. Matches preceding pattern zero or more times
  137. ``+``
  138. Matches preceding pattern one or more times
  139. ``?``
  140. Matches preceding pattern zero or once only
  141. ``|``
  142. Matches a pattern on either side of the ``|``
  143. ``()``
  144. Saves a matched subexpression, which can be referenced
  145. in the ``REGEX REPLACE`` operation.
  146. .. versionadded:: 3.9
  147. All regular expression-related commands, including e.g.
  148. :command:`if(MATCHES)`, save subgroup matches in the variables
  149. :variable:`CMAKE_MATCH_<n>` for ``<n>`` 0..9.
  150. .. noqa: spellcheck off
  151. ``*``, ``+`` and ``?`` have higher precedence than concatenation. ``|``
  152. has lower precedence than concatenation. This means that the regular
  153. expression ``^ab+d$`` matches ``abbd`` but not ``ababd``, and the regular
  154. expression ``^(ab|cd)$`` matches ``ab`` but not ``abd``.
  155. .. noqa: spellcheck on
  156. CMake language :ref:`Escape Sequences` such as ``\t``, ``\r``, ``\n``,
  157. and ``\\`` may be used to construct literal tabs, carriage returns,
  158. newlines, and backslashes (respectively) to pass in a regex. For example:
  159. * The quoted argument ``"[ \t\r\n]"`` specifies a regex that matches
  160. any single whitespace character.
  161. * The quoted argument ``"[/\\]"`` specifies a regex that matches
  162. a single forward slash ``/`` or backslash ``\``.
  163. * The quoted argument ``"[A-Za-z0-9_]"`` specifies a regex that matches
  164. any single "word" character in the C locale.
  165. * The quoted argument ``"\\(\\a\\+b\\)"`` specifies a regex that matches
  166. the exact string ``(a+b)``. Each ``\\`` is parsed in a quoted argument
  167. as just ``\``, so the regex itself is actually ``\(\a\+\b\)``. This
  168. can alternatively be specified in a :ref:`bracket argument` without
  169. having to escape the backslashes, e.g. ``[[\(\a\+\b\)]]``.
  170. Manipulation
  171. ^^^^^^^^^^^^
  172. .. signature::
  173. string(APPEND <string_variable> [<input>...])
  174. .. versionadded:: 3.4
  175. Append all the ``<input>`` arguments to the string.
  176. .. signature::
  177. string(PREPEND <string_variable> [<input>...])
  178. .. versionadded:: 3.10
  179. Prepend all the ``<input>`` arguments to the string.
  180. .. signature::
  181. string(CONCAT <output_variable> [<input>...])
  182. Concatenate all the ``<input>`` arguments together and store
  183. the result in the named ``<output_variable>``.
  184. .. signature::
  185. string(JOIN <glue> <output_variable> [<input>...])
  186. .. versionadded:: 3.12
  187. Join all the ``<input>`` arguments together using the ``<glue>``
  188. string and store the result in the named ``<output_variable>``.
  189. To join a list's elements, prefer to use the ``JOIN`` operator
  190. from the :command:`list` command. This allows for the elements to have
  191. special characters like ``;`` in them.
  192. .. signature::
  193. string(TOLOWER <string> <output_variable>)
  194. Convert ``<string>`` to lower characters.
  195. .. signature::
  196. string(TOUPPER <string> <output_variable>)
  197. Convert ``<string>`` to upper characters.
  198. .. signature::
  199. string(LENGTH <string> <output_variable>)
  200. Store in an ``<output_variable>`` a given string's length in bytes.
  201. Note that this means if ``<string>`` contains multi-byte characters,
  202. the result stored in ``<output_variable>`` will *not* be
  203. the number of characters.
  204. .. signature::
  205. string(SUBSTRING <string> <begin> <length> <output_variable>)
  206. Store in an ``<output_variable>`` a substring of a given ``<string>``. If
  207. ``<length>`` is ``-1`` the remainder of the string starting at ``<begin>``
  208. will be returned.
  209. .. versionchanged:: 3.2
  210. If ``<string>`` is shorter than ``<length>``
  211. then the end of the string is used instead.
  212. Previous versions of CMake reported an error in this case.
  213. Both ``<begin>`` and ``<length>`` are counted in bytes, so care must
  214. be exercised if ``<string>`` could contain multi-byte characters.
  215. .. signature::
  216. string(STRIP <string> <output_variable>)
  217. Store in an ``<output_variable>`` a substring of a given ``<string>``
  218. with leading and trailing spaces removed.
  219. .. signature::
  220. string(GENEX_STRIP <string> <output_variable>)
  221. .. versionadded:: 3.1
  222. Strip any :manual:`generator expressions <cmake-generator-expressions(7)>`
  223. from the input ``<string>`` and store the result
  224. in the ``<output_variable>``.
  225. .. signature::
  226. string(REPEAT <string> <count> <output_variable>)
  227. .. versionadded:: 3.15
  228. Produce the output string as the input ``<string>``
  229. repeated ``<count>`` times.
  230. .. signature::
  231. string(REGEX QUOTE <out-var> <input>...)
  232. .. versionadded:: 4.2
  233. Store in an ``<out-var>`` a regular expression matching the ``<input>``.
  234. All characters that have special meaning in a regular expression are
  235. escaped, such that the output string can be used as part of a regular
  236. expression to match the input literally.
  237. Comparison
  238. ^^^^^^^^^^
  239. .. _COMPARE:
  240. .. signature::
  241. string(COMPARE LESS <string1> <string2> <output_variable>)
  242. string(COMPARE GREATER <string1> <string2> <output_variable>)
  243. string(COMPARE EQUAL <string1> <string2> <output_variable>)
  244. string(COMPARE NOTEQUAL <string1> <string2> <output_variable>)
  245. string(COMPARE LESS_EQUAL <string1> <string2> <output_variable>)
  246. string(COMPARE GREATER_EQUAL <string1> <string2> <output_variable>)
  247. Compare the strings and store true or false in the ``<output_variable>``.
  248. .. versionadded:: 3.7
  249. Added the ``LESS_EQUAL`` and ``GREATER_EQUAL`` options.
  250. .. _`Supported Hash Algorithms`:
  251. Hashing
  252. ^^^^^^^
  253. .. signature::
  254. string(<HASH> <output_variable> <input>)
  255. :target: <HASH>
  256. Compute a cryptographic hash of the ``<input>`` string.
  257. The supported ``<HASH>`` algorithm names are:
  258. ``MD5``
  259. Message-Digest Algorithm 5, RFC 1321.
  260. ``SHA1``
  261. US Secure Hash Algorithm 1, RFC 3174.
  262. ``SHA224``
  263. US Secure Hash Algorithms, RFC 4634.
  264. ``SHA256``
  265. US Secure Hash Algorithms, RFC 4634.
  266. ``SHA384``
  267. US Secure Hash Algorithms, RFC 4634.
  268. ``SHA512``
  269. US Secure Hash Algorithms, RFC 4634.
  270. ``SHA3_224``
  271. Keccak SHA-3.
  272. ``SHA3_256``
  273. Keccak SHA-3.
  274. ``SHA3_384``
  275. Keccak SHA-3.
  276. ``SHA3_512``
  277. Keccak SHA-3.
  278. .. versionadded:: 3.8
  279. Added the ``SHA3_*`` hash algorithms.
  280. Generation
  281. ^^^^^^^^^^
  282. .. signature::
  283. string(ASCII <number> [<number> ...] <output_variable>)
  284. Convert all numbers into corresponding ASCII characters.
  285. .. signature::
  286. string(HEX <string> <output_variable>)
  287. .. versionadded:: 3.18
  288. Convert each byte in the input ``<string>`` to its hexadecimal representation
  289. and store the concatenated hex digits in the ``<output_variable>``.
  290. Letters in the output (``a`` through ``f``) are in lowercase.
  291. .. signature::
  292. string(CONFIGURE <string> <output_variable>
  293. [@ONLY] [ESCAPE_QUOTES])
  294. Transform a ``<string>`` like :command:`configure_file` transforms a file.
  295. .. signature::
  296. string(MAKE_C_IDENTIFIER <string> <output_variable>)
  297. Convert each non-alphanumeric character in the input ``<string>`` to an
  298. underscore and store the result in the ``<output_variable>``. If the first
  299. character of the ``<string>`` is a digit, an underscore will also be
  300. prepended to the result.
  301. .. signature::
  302. string(RANDOM [LENGTH <length>] [ALPHABET <alphabet>]
  303. [RANDOM_SEED <seed>] <output_variable>)
  304. Return a random string of given ``<length>`` consisting of
  305. characters from the given ``<alphabet>``. Default length is 5 characters
  306. and default alphabet is all numbers and upper and lower case letters.
  307. If an integer ``RANDOM_SEED`` is given, its value will be used to seed the
  308. random number generator.
  309. .. signature::
  310. string(TIMESTAMP <output_variable> [<format_string>] [UTC])
  311. Write a string representation of the current date
  312. and/or time to the ``<output_variable>``.
  313. If the command is unable to obtain a timestamp, the ``<output_variable>``
  314. will be set to the empty string ``""``.
  315. The optional ``UTC`` flag requests the current date/time representation to
  316. be in Coordinated Universal Time (UTC) rather than local time.
  317. The optional ``<format_string>`` may contain the following format
  318. specifiers:
  319. ``%%``
  320. .. versionadded:: 3.8
  321. A literal percent sign (%).
  322. ``%d``
  323. The day of the current month (01-31).
  324. ``%H``
  325. The hour on a 24-hour clock (00-23).
  326. ``%I``
  327. The hour on a 12-hour clock (01-12).
  328. ``%j``
  329. The day of the current year (001-366).
  330. ``%m``
  331. The month of the current year (01-12).
  332. ``%b``
  333. .. versionadded:: 3.7
  334. Abbreviated month name (e.g. Oct).
  335. ``%B``
  336. .. versionadded:: 3.10
  337. Full month name (e.g. October).
  338. ``%M``
  339. The minute of the current hour (00-59).
  340. ``%s``
  341. .. versionadded:: 3.6
  342. Seconds since midnight (UTC) 1-Jan-1970 (UNIX time).
  343. ``%S``
  344. The second of the current minute. 60 represents a leap second. (00-60)
  345. ``%f``
  346. .. versionadded:: 3.23
  347. The microsecond of the current second (000000-999999).
  348. ``%U``
  349. The week number of the current year (00-53).
  350. ``%V``
  351. .. versionadded:: 3.22
  352. The ISO 8601 week number of the current year (01-53).
  353. ``%w``
  354. The day of the current week. 0 is Sunday. (0-6)
  355. ``%a``
  356. .. versionadded:: 3.7
  357. Abbreviated weekday name (e.g. Fri).
  358. ``%A``
  359. .. versionadded:: 3.10
  360. Full weekday name (e.g. Friday).
  361. ``%y``
  362. The last two digits of the current year (00-99).
  363. ``%Y``
  364. The current year.
  365. ``%z``
  366. .. versionadded:: 3.26
  367. The offset of the time zone from UTC, in hours and minutes,
  368. with format ``+hhmm`` or ``-hhmm``.
  369. ``%Z``
  370. .. versionadded:: 3.26
  371. The time zone name.
  372. Unknown format specifiers will be ignored and copied to the output
  373. as-is.
  374. If no explicit ``<format_string>`` is given, it will default to:
  375. * ``%Y-%m-%dT%H:%M:%S`` for local time.
  376. * ``%Y-%m-%dT%H:%M:%SZ`` for UTC.
  377. .. versionadded:: 3.8
  378. If the ``SOURCE_DATE_EPOCH`` environment variable is set,
  379. its value will be used instead of the current time.
  380. See https://reproducible-builds.org/specs/source-date-epoch/ for details.
  381. .. signature::
  382. string(UUID <output_variable> NAMESPACE <namespace> NAME <name>
  383. TYPE <MD5|SHA1> [UPPER])
  384. .. versionadded:: 3.1
  385. Create a universally unique identifier (aka GUID) as per RFC4122
  386. based on the hash of the combined values of ``<namespace>``
  387. (which itself has to be a valid UUID) and ``<name>``.
  388. The hash algorithm can be either ``MD5`` (Version 3 UUID) or
  389. ``SHA1`` (Version 5 UUID).
  390. A UUID has the format ``xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx``
  391. where each ``x`` represents a lower case hexadecimal character.
  392. Where required, an uppercase representation can be requested
  393. with the optional ``UPPER`` flag.
  394. .. _JSON:
  395. JSON
  396. ^^^^
  397. .. versionadded:: 3.19
  398. Functionality for querying a JSON string.
  399. .. note::
  400. In each of the following JSON-related subcommands, if the optional
  401. ``ERROR_VARIABLE`` argument is given, errors will be reported in
  402. ``<error-variable>`` and the ``<out-var>`` will be set to
  403. ``<member|index>-[<member|index>...]-NOTFOUND`` with the path elements
  404. up to the point where the error occurred, or just ``NOTFOUND`` if there
  405. is no relevant path. If an error occurs but the ``ERROR_VARIABLE``
  406. option is not present, a fatal error message is generated. If no error
  407. occurs, the ``<error-variable>`` will be set to ``NOTFOUND``.
  408. In the following subcommands, the ``<json-string>`` argument should
  409. be written as a :ref:`Quoted Argument` to ensure the entire JSON
  410. string is passed as a single argument even if it contains semicolons.
  411. .. signature::
  412. string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
  413. GET <json-string> [<member|index> ...])
  414. :target: JSON-GET
  415. Get an element from ``<json-string>`` at the location given
  416. by the list of ``<member|index>`` arguments.
  417. Array and object elements will be returned as a JSON string.
  418. Boolean elements will be returned as ``ON`` or ``OFF``.
  419. Null elements will be returned as an empty string.
  420. Number and string types will be returned as strings.
  421. .. signature::
  422. string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
  423. GET_RAW <json-string> [<member|index> ...])
  424. :target: JSON-GET-RAW
  425. Get an element from ``<json-string>`` at the location given
  426. by the list of ``<member|index>`` arguments. Similar to
  427. `GET <JSON-GET_>`__, but does not convert number, string,
  428. boolean, or null elements.
  429. .. signature::
  430. string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
  431. TYPE <json-string> [<member|index> ...])
  432. :target: JSON-TYPE
  433. Get the type of an element in ``<json-string>`` at the location
  434. given by the list of ``<member|index>`` arguments. The ``<out-var>``
  435. will be set to one of ``NULL``, ``NUMBER``, ``STRING``, ``BOOLEAN``,
  436. ``ARRAY``, or ``OBJECT``.
  437. .. signature::
  438. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  439. MEMBER <json-string>
  440. [<member|index> ...] <index>)
  441. :target: JSON-MEMBER
  442. Get the name of the ``<index>``-th member in ``<json-string>``
  443. at the location given by the list of ``<member|index>`` arguments.
  444. Requires an element of object type.
  445. .. signature::
  446. string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
  447. LENGTH <json-string> [<member|index> ...])
  448. :target: JSON-LENGTH
  449. Get the length of an element in ``<json-string>`` at the location
  450. given by the list of ``<member|index>`` arguments.
  451. Requires an element of array or object type.
  452. .. signature::
  453. string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
  454. REMOVE <json-string> <member|index> [<member|index> ...])
  455. :target: JSON-REMOVE
  456. Remove an element from ``<json-string>`` at the location
  457. given by the list of ``<member|index>`` arguments. The JSON string
  458. without the removed element will be stored in ``<out-var>``.
  459. .. signature::
  460. string(JSON <out-var> [ERROR_VARIABLE <error-variable>]
  461. SET <json-string> <member|index> [<member|index> ...] <value>)
  462. :target: JSON-SET
  463. Set an element in ``<json-string>`` at the location
  464. given by the list of ``<member|index>`` arguments to ``<value>``.
  465. The contents of ``<value>`` should be valid JSON.
  466. If ``<json-string>`` is an array, ``<value>`` can be appended to the end of
  467. the array by using a number greater or equal to the array length as the
  468. ``<member|index>`` argument.
  469. .. signature::
  470. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  471. EQUAL <json-string1> <json-string2>)
  472. :target: JSON-EQUAL
  473. Compare the two JSON objects given by ``<json-string1>``
  474. and ``<json-string2>`` for equality. The contents of ``<json-string1>``
  475. and ``<json-string2>`` should be valid JSON. The ``<out-var>``
  476. will be set to a true value if the JSON objects are considered equal,
  477. or a false value otherwise.
  478. .. signature::
  479. string(JSON <out-var> [ERROR_VARIABLE <error-var>]
  480. STRING_ENCODE <string>)
  481. :target: STRING-ENCODE
  482. Turn a raw string into a JSON string surrounded by quotes. Special characters
  483. will be properly escaped inside the JSON string.