You need to wrap your input and button in a form tag with and action attribute and a method attribute (assuming you are in php).
The action attribute refers to the page processing your results, and the method attribute is the action used to send your form data to the server.
In your action page, you need to get the parameters sent from your page with a $_GET[param] or $_POST[param] depending on the value of your method attribute.
Then you can write the value in a file with the json_encode function in PHP
For exemple:
index.php (note the .php)
<form action='somepage.php' method='GET'>
<input type="text" name="text" placeholder="txt">
<button type="submit">Save<button>
</form>
somepage.php
//get the results
$txt=$_GET['text']
$array = ["text"=>$txt]
//write the result in a text file
$json = json_encode($array)
$file=fopen('jsondb.json')
fwrite($file,$json)
fclose($file)