Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.
Expected Behavior
Conversion from JSON to XML finalizes successfully
Current Behavior
An IndexError: basic_string::at is returned when attempting a conversion from JSON to XML with payload choice-value:""
The payload is correctly converted from XML to JSON to fail when converted back to XML.
Steps to Reproduce
Issue is shown when attempting to convert the following JSON payload
{
"junos-conf-root:configuration": {
"junos-conf-policy-options:policy-options": {
"policy-statement": [
{
"name": "IPV4",
"term": [
{
"name": "OSPF-ACCEPT",
"from": {
"protocol": [
"ospf"
],
"route-filter": [
{
"address": "1.1.1.0/24",
"choice-ident": "orlonger",
"choice-value": ""
}
]
},
"then": {
"accept": [null]
}
}
]
}
]
}
}
}
Your Script
def yang_yaml_to_xml(json_file):
config_json_yang = json.dumps(json.load(open(json_file)))
print (config_json_yang)
decoded_json_yang = CODEC.decode(JSON_PROVIDER, config_json_yang)
yang_xml = CODEC.encode(XML_PROVIDER, decoded_json_yang)
return yang_xml
Logs
Enable logging and post the logs below
Traceback (most recent call last):
File "convert1.py", line 249, in <module>
print(yang_yaml_to_xml(ARGS['yaml_file']))
File "convert1.py", line 218, in yang_yaml_to_xml
decoded_json_yang = CODEC.decode(JSON_PROVIDER, config_json_yang)
File "/opt/neteng/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 112, in helper
return func(self, provider, entity, *args, **kwargs)
File "/opt/neteng/lib/python3.6/site-packages/ydk/services/codec_service.py", line 140, in decode
return self._decode(provider, payload_holder, subtree)
File "/opt/neteng/lib/python3.6/site-packages/ydk/services/codec_service.py", line 174, in _decode
root_data_node = codec_service.decode(root_schema, payload, provider.encoding)
IndexError: basic_string::at
System Information
Red Hat Enterprise Linux Server release 7.9 (Maipo)
Python 3.6.9
Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.
Expected Behavior
Conversion from JSON to XML finalizes successfully
Current Behavior
An IndexError: basic_string::at is returned when attempting a conversion from JSON to XML with payload choice-value:""
The payload is correctly converted from XML to JSON to fail when converted back to XML.
Steps to Reproduce
Issue is shown when attempting to convert the following JSON payload
Your Script
Logs
Enable logging and post the logs below
System Information
Red Hat Enterprise Linux Server release 7.9 (Maipo)
Python 3.6.9