Sunday, 15 March 2015

symfony2 - Creating json file in Symfony 2 -



symfony2 - Creating json file in Symfony 2 -

hi i've created json object that:

{"ask":[{"rate":"2110.00000000","amount":"2.00000000","price":"4220.00000000","degree":0.2},{"rate":"1800.00000000","amount":"5.00000000","price":"9000.00000000","degree":0.5},{"rate":"20.00000000","amount":"8.00000000","price":"160.00000000","degree":0.8}],"bid":[{"rate":"1700.00000000","amount":"0.50000000","price":"1700.00000000","degree":0.5}]}

and create file , set json it, how can it?

you utilize filesystem component, , dumpfile function.

let's have $json contains json string.

$fs = new \symfony\component\filesystem\filesystem(); seek { $fs->dumpfile('path/to/my/file.json', $json); } catch(ioexception $e) { }

or utilize php functions, such file_put_contents

json symfony2

No comments:

Post a Comment