<div dir="ltr"><div><div><div><div>Hi guys,<br><br></div> I tried with this modules<br> <a href="https://github.com/talentdeficit/jsx" target="_blank">https://github.com/<wbr>talentdeficit/jsx</a>,<br><a href="https://github.com/davisp/jiffy" target="_blank"> https://github.com/davisp/<wbr>jiffy</a><br><br><br></div>But its need fieldname. My Sql driver returns data like below <br><br><br><b>for checking Sql result {{metadata,2,0,<br> {server_status,false,true,false,false,true,<br> false,false,false,false,false,false,false},<br> [{field_metadata,"def","zurik","erlang",<br> "erlang","name","name",33,135,253,<br> <<0,0>>,<br> 0,[]},<br> {field_metadata,"def","zurik","erlang",<br> "erlang","id","id",63,11,3,<br> <<0,0>>,<br> 0,[]}],<br> []},<br> [["some",457],["some",457],["data2sosfasfme",42]]}<br><br><br></b></div><div><b>Please find my table structure below</b></div>+----------------+------+<br>| name | id |<br>+----------------+------+<br>| some | 457 |<br>| some | 457 |<br>| data2sosfasfme | 42 |<br>+----------------+------+<br><br><br><br></div>Its that idea to get field name <br><div><div><b></b></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 31 August 2017 at 18:43, Jesper Louis Andersen <span dir="ltr"><<a href="mailto:jesper.louis.andersen@gmail.com" target="_blank">jesper.louis.andersen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>The way Erlang systems handle JSON data is the following:<br><br></div>1. In Erlang, every value passed around is an "Erlang Term".<br></div>2. A subset of these terms are representable in JSON.<br></div>3. JSON encoders such as 'jiffy' or 'jsx' are able to take the valid subset from 2 and convert it into a binary containing the equivalent JSON representation.<br><br></div>Your problem can be solved by taking the data you obtain from MySQL and then convert the data into a form which follows the valid JSON subset and has the structure you want. Then call something like `jsx:encode(Data)` on your `Data`.</div><div><br></div><div>Some background on 2 above: Erlang terms can contain tuples such as {ok, 37} or {error, not_connected}. These do not have a representation in JSON (since it lacks the equivalent of a symbol/atom and tuples). So most JSON encoders reject Erlang terms containing tuples as subterms. The details depend on the encoder though.<br></div><div><br></div>I can't remember if MySQL is able to return a result set directly as JSON, and if it were, you have to check that the driver you use can handle such a result as well--I can't help you much in this case, unfortunately.<br><br></div>Hopefully this will get you started on a solution!<br></div><br><div class="gmail_quote"><div><div class="h5"><div dir="ltr">On Thu, Aug 31, 2017 at 2:32 PM Palanikumar Gopalakrishnan <<a href="mailto:palani@vahaitech.com" target="_blank">palani@vahaitech.com</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div>I want to get data from mysql and convert them into json format. I tried with this <br><br></div>module <a href="https://sourceforge.net/projects/erlmysql/files/latest/download?source=directory" target="_blank">https://sourceforge.net/<wbr>projects/erlmysql/files/<wbr>latest/download?source=<wbr>directory</a><br><br><br></div>Previously i tried this modules, <br><a href="https://github.com/Eonblast/Emysql" target="_blank">https://github.com/Eonblast/<wbr>Emysql</a></div><div><br><span id="m_56610011443343177m_-331877938721679805goog_2119250159"></span><span id="m_56610011443343177m_-331877938721679805goog_2119250160"></span></div><div>This module give support for json conversion. But It was not support for Transaction.</div><div><br></div><div>So I need to convert Sql return data to Json format. Please guide me to solve this challenge<br></div><div><br></div><div><br></div><div><br></div><div><div><div><div><div><br></div><div><br></div><div><br>-- <br><div class="m_56610011443343177m_-331877938721679805gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><br></div><div><b>Warm Regards,</b></div></div><div><br></div><div><span style="background-color:rgb(255,255,255)"><span style="font-size:12.8px"><b>Palanikumar Gopalakrishnan </b></span></span><img alt="✌" style="font-size:small;margin:0px 0.2ex;vertical-align:middle;height:24px;width:24px"><span style="background-color:rgb(255,255,255)"><br></span></div><div><span style="font-size:12.8px;background-color:rgb(255,255,255)"><b>Developer</b></span><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div>
</div></div></div></div></div></div></div></div>
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
</blockquote></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><br></div><div><b>Warm Regards,</b></div></div><div><br></div><div><span style="background-color:rgb(255,255,255)"><span style="font-size:12.8px"><b>Palanikumar Gopalakrishnan </b></span></span><img src="https://ssl.gstatic.com/mail/emoji/6/48px/emoji_u270c.png" alt="✌" style="font-size:small;margin:0px 0.2ex;vertical-align:middle;height:24px;width:24px"><span style="background-color:rgb(255,255,255)"><br></span></div><div><span style="font-size:12.8px;background-color:rgb(255,255,255)"><b>Developer</b></span><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div>
</div>