Is there a resonably easy way to in C convert a tree struct such as the below to JSON? For easy read and write to files and store between executions?
Or in another format perhaps (I only choose JSON because I am more experienced with it).
struct node {
datatype data; // whatever data is inside the node
struct node *left_ptr; // may be NULL
struct node *right_ptr; // may be NULL
}
Thanks,
Sure: serialize a null pointer as
null, pick an appropriate representation fordata(let’s call thatdata_repr), then serialize anodeas (pseudocode)