Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot convert undefined or null to object #7

Open
meftunca opened this issue Jun 24, 2024 · 1 comment
Open

TypeError: Cannot convert undefined or null to object #7

meftunca opened this issue Jun 24, 2024 · 1 comment

Comments

@meftunca
Copy link
Collaborator

meftunca commented Jun 24, 2024

JSON and most languages do not support undefined values, and this is how the write_beve function on beve js throws an error for the undefined value passed to it. This is a potential bug for the js. Something needs to be done about this.

Suggestion,

  1. remove Object values with undefined values (like browsers do in rest api requests)
  2. We can convert Array elements with undefined value to null

I was able to solve the problem by adding a new "if" branch under write_value.

else if (value === null) {
        let header = 0;
        header |= 0b00000000;
        writer.append_uint8(header);
    } 
@stephenberry
Copy link
Collaborator

I like your suggestion, I think undefined object values should be removed and array elements changed to null. Good thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants