First, copy (also called 'yank' in vim parlance) your visual selection to the register of your choice. For example, to copy to register 'z', make your visual selection, and then type "zy
.
In the case you give, you could do this without moving the cursor, by putting the cursor on the first square brace, and then typing v%"zy
.
Breakdown: v
-> start visual selection; %
-> move to matching brace; "z
-> use register 'z'; y
-> yank (copy) the selection (in this case, into register 'z').
Once you have copied your visual selection to register 'z', go to the command line, and type
call writefile(getreg('z', 1, 1), "some-file")
If you want to append the text, rather than overwrite, you can use the "a" flag as follows
call writefile(getreg('z', 1, 1), "some-file", "a")