Add to_json method for Node.