mirror of
https://github.com/bringout/oca-ocb-report.git
synced 2026-04-20 22:22:08 +02:00
19.0 vanilla
This commit is contained in:
parent
62d197ac8b
commit
184bb0e321
667 changed files with 691406 additions and 239886 deletions
17
odoo-bringout-oca-ocb-spreadsheet/spreadsheet/utils/json.py
Normal file
17
odoo-bringout-oca-ocb-spreadsheet/spreadsheet/utils/json.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
def extend_serialized_json(json: str, key_value_pairs: list) -> str:
|
||||
"""
|
||||
Add key-value pairs to a serialized JSON object string.
|
||||
value should be already serialized.
|
||||
"""
|
||||
# avoid copying strings as much as possible for performance reasons
|
||||
parts = [json.removesuffix('}')]
|
||||
if json != '{}':
|
||||
parts.append(',')
|
||||
for i, (key, value) in enumerate(key_value_pairs):
|
||||
parts.extend([f'"{key}":', value])
|
||||
if i != len(key_value_pairs) - 1:
|
||||
parts.append(',')
|
||||
parts.append('}')
|
||||
return ''.join(parts)
|
||||
Loading…
Add table
Add a link
Reference in a new issue