mirror of
https://github.com/pocketpy/pocketpy
synced 2026-03-21 20:50:16 +00:00
Compare commits
3 Commits
87c60a688a
...
bfb44e8618
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfb44e8618 | ||
|
|
e650904788 | ||
|
|
f6c6a48de4 |
@ -104,7 +104,9 @@ static bool mpack_write_dict_kv(py_Ref k, py_Ref v, void* ctx) {
|
|||||||
if(k->type != tp_str) return TypeError("msgpack: key must be strings");
|
if(k->type != tp_str) return TypeError("msgpack: key must be strings");
|
||||||
c11_sv sv = py_tosv(k);
|
c11_sv sv = py_tosv(k);
|
||||||
mpack_write_str(writer, sv.data, (size_t)sv.size);
|
mpack_write_str(writer, sv.data, (size_t)sv.size);
|
||||||
return py_to_mpack(v, writer);
|
bool ok = py_to_mpack(v, writer);
|
||||||
|
if(!ok) mpack_write_nil(writer);
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool py_to_mpack(py_Ref object, mpack_writer_t* writer) {
|
static bool py_to_mpack(py_Ref object, mpack_writer_t* writer) {
|
||||||
|
|||||||
@ -5,6 +5,16 @@ label: json
|
|||||||
|
|
||||||
JSON serialization and deserialization module.
|
JSON serialization and deserialization module.
|
||||||
|
|
||||||
|
This module is not safe. You may not want to use it with untrusted data.
|
||||||
|
If you need a safe alternative, consider a 3rd-party library like `cjson`.
|
||||||
|
|
||||||
|
You can override the json functions with:
|
||||||
|
```c
|
||||||
|
py_GlobalRef mod = py_getmodule("json");
|
||||||
|
py_bindfunc(mod, "loads", _safe_json_loads);
|
||||||
|
py_bindfunc(mod, "dumps", _safe_json_dumps);
|
||||||
|
```
|
||||||
|
|
||||||
#### Source code
|
#### Source code
|
||||||
|
|
||||||
:::code source="../../include/typings/json.pyi" :::
|
:::code source="../../include/typings/json.pyi" :::
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user