7 Commits

Author SHA1 Message Date
George Kiagiadakis
d07b6188e5 spa-json: add new "undefined" parser constructor
This allows reading non-standard JSON data that is not a valid JSON
object or array, but can be treated as such.
2024-03-04 07:07:56 +00:00
George Kiagiadakis
42b64bfc28 spa-json: rename _from_string() to _wrap_string() and add new "from" variants
The previous naming convention was confusing because it did not make
it explicit that the string is not being copied. We had this wrong already
in the Lua bindings and thanks to some miracle it hasn't backfired so far
(it was using the "wrap" behaviour with a string that doesn't stay alive).

In some places we actually need the "copy" behaviour and in some other
places we need the "wrap" behaviour, so let's have both variants available.
2023-11-14 12:36:10 +02:00
Julian Bouzas
9f2168e022 spa-json: add _add_from_string() and _add_from_stringn() builder APIs 2023-04-17 07:47:09 -04:00
Ashok Sidipotu
229f5d0630 spa-json: add _is_container () API 2023-04-17 07:44:19 -04:00
Julian Bouzas
0996f5a5ca spa-json: add wp_spa_json_to_string() API
Since the string length returned by wp_spa_pod_get_data() does not always match
the size of the actual json object because it is stored in contiguous memory, we
cannot always rely on that API to get the json string data.

The new wp_spa_pod_to_string() always allocates a new string with the same
length as the json size, guaranteeing that the string returned always represents
the json object, regardless of whether it is nested or not. It is always
recommented to use wp_spa_pod_to_string() unless you know what you are doing.
2022-06-27 10:07:16 +00:00
Julian Bouzas
e9be326954 spa-json: add _new_from_stringn() API 2022-03-24 04:35:12 -04:00
Julian Bouzas
4c1574117a spa-json: add new WpSpaJson API 2022-01-25 07:20:35 -05:00