I'm building a form in Retool that includes a few JSON editor fields. Since the editor expects a specific structure (like an object, a list of objects, or values of type string or number), I've been relying on the "valid" property to check whether the input is correct.
On valid input, everything works fine. For example, if I enter [{"key":"value"}], the editor returns valid = true and the correct value.
But here's the issue: if the next input is invalid β for example, just a plain string like "invalid_data" β then the "valid" property becomes false, which is expected. However, the "value" property still returns the last valid value (in this case, [{"key":"value"}]).
This creates a problem because while I know the input is invalid, I can't access what the user actually typed. There's no way to retrieve the raw invalid input, which makes it impossible to provide feedback or try to correct the data through scripts.
Is there a way to access the raw input when it's invalid? Or is this a known limitation of the JSON editor?
Also, side note: it would be great if users could resize the JSON editor at runtime. Right now, it's fixed in size once the app is published, which can make it harder to work with large or nested JSON.
Hey Hermal!
Have you tried creating variables and setting them whenever the input changes? So that maybe you can create two variables such as "validJson" and "invalidJsonValue", and get the data from there.
Keep me posted and please mark this as a solution if it resolved your problem!
I have not tried the way you mentioned but that would require assigning values to variable and carefully setting them null before next using it again.
I would expect a form to pass the data which user entered ignoring the fact it is wrong format or something else rather than fetching values from last submission call.
Additionally i did clear and reset form fields at each submission still its fetching old values i don't understand why.
Can you share with me how you set up editor to expect a specific structure? I am looking to reproduce this to confirm the bug.
On invalid data, the form should reset the inputs, then when you enter in a plain string like "invalid_data" it should properly update the the component's value to the new invalid string and not continue to return the previously valid [{"key":"value"}]