The looks like a solution! Many thanks!!
But maybe there is potential for improvements, so in order to answer your questions and in order to explain better what I do on python side:
I have a function on python side, which converts an ion object into python:
def get_result(cursor):
"""
Pretty print the result set. Returns the number of documents in the result set.
:type cursor: :py:class:`pyqldb.cursor.stream_cursor.StreamCursor`/
:py:class:`pyqldb.cursor.buffered_cursor.BufferedCursor`
:param cursor: An instance of the StreamCursor or BufferedCursor class.
:rtype: int
:return: Number of documents in the result set.
"""
result = []
for row in cursor:
# Each row would be in Ion format.
result.append(dumps(row, binary=False,
omit_version_marker=True))
return result
When I print this function in python or call it via erlport in elixir and make an IO.inspect() I get the following result in iex (this time with original and not example data):
['{version:"BGBl. II Nr. 163/2007",valid:true,url:"https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=20005279",subject:"Einweisungsbest\\xe4tigung",state:"in use",retrieved_on:null,name:"Medizinproduktebetreiberverordnung (MPBV)",id:null,country:"AT",confirmation_template:[]}', '{subject:"Einweisungsbest\\xe4tigung",name:"Medizinproduktebetreiberverordnung (MPBV)",country:"AT",url:"https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=20005279",retrieved_on:2019-12-21T00:00:00.000000-00:00,version:"BGBl. II Nr. 163/2007",state:"in use",valid:true}']
So in this case, I get a single quoted result.
I also tried to convert this object on python side to json:
def get_result(cursor):
"""
Pretty print the result set. Returns the number of documents in the result set.
:type cursor: :py:class:`pyqldb.cursor.stream_cursor.StreamCursor`/
:py:class:`pyqldb.cursor.buffered_cursor.BufferedCursor`
:param cursor: An instance of the StreamCursor or BufferedCursor class.
:rtype: int
:return: Number of documents in the result set.
"""
result = []
for row in cursor:
# Each row would be in Ion format.
result.append(json.dumps(dumps(row, binary=False,
omit_version_marker=True)))
return result
The result of “already converted to json on python side” is as I posted before single and double quoted:
['"{version:\\"BGBl. II Nr. 163/2007\\",valid:true,url:\\"https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=20005279\\",subject:\\"Einweisungsbest\\\\xe4tigung\\",state:\\"in use\\",retrieved_on:null,name:\\"Medizinproduktebetreiberverordnung (MPBV)\\",id:null,country:\\"AT\\",confirmation_template:[]}"', '"{subject:\\"Einweisungsbest\\\\xe4tigung\\",name:\\"Medizinproduktebetreiberverordnung (MPBV)\\",country:\\"AT\\",url:\\"https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=20005279\\",retrieved_on:2019-12-21T00:00:00.000000-00:00,version:\\"BGBl. II Nr. 163/2007\\",state:\\"in use\\",valid:true}"']