How can i send id of the currently posted form data through json response in custom wordpress plugin?

From an example in the Developer Reference:

To get the id of the inserted object use $wpdb->insert_id;

global $wpdb;
$table = $wpdb->prefix.'you_table_name';
$data = array('column1' => 'data one', 'column2' => 123);
$format = array('%s','%d');
$wpdb->insert($table,$data,$format);
$my_id = $wpdb->insert_id;