Export MySQL to Json: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 12: Line 12:


</pre>
</pre>
== Datas.json ==
<pre>
[
{"Menue":"1", "TextD":"Sake"},
{"Menue":"2", "TextD":"Maguro"},
{"Menue":"3", "TextD":"Mutsu"},
{"Menue":"4", "TextD":"Izumidai"},
{"Menue":"5", "TextD":"Amaebi"},
{"Menue":"6", "TextD":"Ebi"},
{"Menue":"7", "TextD":"Kanikama"},
{"Menue":"8", "TextD":"Avocado"},
{"Menue":"9", "TextD":"Tamago"}
]
</pre>


== Parse the Result ==
== Parse the Result ==

Revision as of 13:32, 4 October 2013


SET SESSION group_concat_max_len = 100000000;

SELECT
  CONCAT("[",
   GROUP_CONCAT(
       CONCAT("{ \"Menue\":  \" ",  Menue  , " \" "),
       CONCAT(", \"Text_D\": \" ",  Text_D), " \"}")
       ,"]")
AS json FROM menu ;


Datas.json

[
{"Menue":"1", "TextD":"Sake"},
{"Menue":"2", "TextD":"Maguro"},
{"Menue":"3", "TextD":"Mutsu"},
{"Menue":"4", "TextD":"Izumidai"},
{"Menue":"5", "TextD":"Amaebi"},
{"Menue":"6", "TextD":"Ebi"},
{"Menue":"7", "TextD":"Kanikama"},
{"Menue":"8", "TextD":"Avocado"},
{"Menue":"9", "TextD":"Tamago"}
]


Parse the Result