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

bug/regression: bool or number value does not show when remove_empty_properties=true and use_default_values=false #1528

Open
skyshore2001 opened this issue Apr 4, 2024 · 0 comments
Assignees

Comments

@skyshore2001
Copy link

General information

  • json-editor version: 98f85cd (2.14.1+)
    It's regression. The good version is 5c0b1de (2.6.1+)

use options:

        remove_empty_properties: true,
        use_default_values: false,

string value shows, but bool or number value does not show.

test code:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Basic JSON Editor Example</title>
    <!--script src="jsoneditor.min.js"></script-->
    <script src="dist/jsoneditor.js"></script>
  </head>
  <body>
    <h1>Basic JSON Editor Example</h1>

    <div id='editor_holder'></div>
    <button id='submit'>Submit (console.log)</button>

    <script>
      var startval = {
        a: true,
        b: 99,
//        type: "ZUSB",
        ranges: [0,1,2],
      };

      // Initialize the editor with a JSON schema
      var editor = new JSONEditor(document.getElementById('editor_holder'),{
        schema: {
          type: "object",
          title: "root",
          properties: {
            a: {
              type:"boolean",
            },
            c: {
              type:"boolean",
            },
            type: {
              type:"string",
              enum: ["USB","ZUSB","NET"],
              default: "ZUSB"
            },
            ranges: {
              type: "array",
              format: "table",
              items: {
                type: "integer"
              }
            }
          }
        },
        startval: startval,
        remove_empty_properties: true,
        use_default_values: false,
        show_opt_in: true
      });
      document.getElementById('submit').addEventListener('click',function() {
        console.log(editor.getValue());
      });
    </script>
  </body>
</html>

Expected behavior

  • variable a, b show true, 99 respectively with option checked; variable type is show 'ZUSB' as default value with option not checked
  • the checkbox can be checked by clicking the label of the checkbox. (another minor issue)

The action is correct on version 2.6.1+ (revision 5c0b1de).

image

Actual behavior

  • variable a, b are empty (option checked); variable type is empty (option not checked)
  • the checkbox cannot be checked by clicking the label of the checkbox.

image

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

No branches or pull requests

3 participants