libyang icon indicating copy to clipboard operation
libyang copied to clipboard

Only last set of changes are visible when used lyd_parse_data_mem() multiple times

Open amitnagraj opened this issue 2 years ago • 3 comments

Hi,

I m trying to fetch the data using lyd_parse_data_mem() subscribing at the parent level(which also includes list inside it). I m filling the values by forming string of json format and passing it the lyd_parse_data_mem() API. I'm using the API multiple times to fill multiple list levels. But only the data which is filled last is visible by this method.

Is there any way so that the data will amend every time when i use this API?

Sysrepo version used: 2.2.12 Libyang Version used: 2.1.4

amitnagraj avatar May 03 '23 11:05 amitnagraj

I would suggest to parse the data into a local variable and then append that to the final tree, lyd_parse_data_mem() is not able to append data to an existing tree.

michalvasko avatar May 03 '23 11:05 michalvasko

Thanks for the quick response.

Parsing the data locally will be costly when dealing with the large scale datasets, Is there any other way like lyd_new_path() which is able to append the data everytime.

amitnagraj avatar May 03 '23 11:05 amitnagraj

Parsing the data locally will be costly when dealing with the large scale datasets

I do not understand why it should, you said you had already been parsing it one-by-one. Just store the result in a local variable and append it. It depend on the exact data you are parsing and the tree you are constructing but I guarantee that there is a (simple) way of not affecting the performance in any way.

michalvasko avatar May 03 '23 11:05 michalvasko