Skip to content

Commit a5a2698

Browse files
committed
data: option to allow json int/bool as strings
Depends on CESNET/libyang#2344 Add support for new option to python bindings. Signed-off-by: Brad House <[email protected]>
1 parent d8acc34 commit a5a2698

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

cffi/cdefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ LY_ERR lyd_print_all(struct ly_out *, const struct lyd_node *, LYD_FORMAT, uint3
321321
#define LYD_PARSE_OPTS_MASK ...
322322
#define LYD_PARSE_ORDERED ...
323323
#define LYD_PARSE_STRICT ...
324+
#define LYD_PARSE_JSON_STRING_DATATYPES ...
324325

325326
#define LYD_VALIDATE_NO_STATE ...
326327
#define LYD_VALIDATE_PRESENT ...

libyang/context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ def parse_data(
533533
validate_multi_error: bool = False,
534534
store_only: bool = False,
535535
json_null: bool = False,
536+
json_string_datatypes: bool = False,
536537
) -> Optional[DNode]:
537538
if self.cdata is None:
538539
raise RuntimeError("context already destroyed")
@@ -545,6 +546,7 @@ def parse_data(
545546
strict=strict,
546547
store_only=store_only,
547548
json_null=json_null,
549+
json_string_datatypes=json_string_datatypes,
548550
)
549551
validation_flgs = validation_flags(
550552
no_state=no_state,
@@ -604,6 +606,7 @@ def parse_data_mem(
604606
validate_multi_error: bool = False,
605607
store_only: bool = False,
606608
json_null: bool = False,
609+
json_string_datatypes: bool = False,
607610
) -> Optional[DNode]:
608611
return self.parse_data(
609612
fmt,
@@ -620,6 +623,7 @@ def parse_data_mem(
620623
validate_multi_error=validate_multi_error,
621624
store_only=store_only,
622625
json_null=json_null,
626+
json_string_datatypes=json_string_datatypes,
623627
)
624628

625629
def parse_data_file(
@@ -637,6 +641,7 @@ def parse_data_file(
637641
validate_multi_error: bool = False,
638642
store_only: bool = False,
639643
json_null: bool = False,
644+
json_string_datatypes: bool = False,
640645
) -> Optional[DNode]:
641646
return self.parse_data(
642647
fmt,
@@ -653,6 +658,7 @@ def parse_data_file(
653658
validate_multi_error=validate_multi_error,
654659
store_only=store_only,
655660
json_null=json_null,
661+
json_string_datatypes=json_string_datatypes,
656662
)
657663

658664
def __iter__(self) -> Iterator[Module]:

libyang/data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def parser_flags(
117117
strict: bool = False,
118118
store_only: bool = False,
119119
json_null: bool = False,
120+
json_string_datatypes: bool = False,
120121
) -> int:
121122
flags = 0
122123
if lyb_mod_update:
@@ -135,6 +136,8 @@ def parser_flags(
135136
flags |= lib.LYD_PARSE_STORE_ONLY
136137
if json_null:
137138
flags |= lib.LYD_PARSE_JSON_NULL
139+
if json_string_datatypes:
140+
flags |= lib.LYD_PARSE_JSON_STRING_DATATYPES
138141
return flags
139142

140143

0 commit comments

Comments
 (0)