How do I get the formEditor json object?

Hi all,

I am trying to implement forms-js editor. I want to extract the json of the form each time it is changed but am having trouble getting the json then displaying it for the user to download or copy as an exact schema.

Here is my code so far:

const createEventListenerForFormEditor = async (formEditor: any) => {
    console.log('create event')
    // Set event listen for when user changes modeler to update modelerXml state
    formEditor.on("changed", async () => {
      // console.log("form schema changed", formEditor.getSchema());
      const schema = await formEditor.saveSchema(emptySchema);
      console.log('schema')
      console.log(schema)
    });
  };

  useEffect(() => {
      const formEditor = new FormEditor({
        container: document.querySelector('#container')
      });
      
      const importSchema = async () => {
        await formEditor.importSchema(emptySchema);
      }

      importSchema()

      createEventListenerForFormEditor(formEditor)
        
  }, [])

As you can see I am console.log(schema) after I save it when the formEditor is updated but it looks like it is coming out as a javascript object and not the schema in json as I need.

Here is schema in the console:

Any help would be greatly appreciated. Thanks

What is your expectation? A JSON string? importSchema and saveSchema both work with objects because for the user it’s trivial to do JSON.parse and JSON.stringify.