Hi Rong, Thank you for this answer. I've changed Rows to Map, which ease the conversion process.
Nevertheless I'm interested in any explanation about why row1.setField(i, row2) appeends row2 at the end of row1. All the best François Le mer. 6 févr. 2019 à 19:33, Rong Rong <walter...@gmail.com> a écrit : > Hi François, > > I wasn't exactly sure this is a JSON object or JSON string you are trying > to process. > For a JSON string this [1] article might help. > For a JSON object, I am assuming you are trying to convert it into a > TableSource and processing using Table/SQL API, you could probably use the > example here [2] > > BTW, a very remote hunch, this might be just a stringify issue how you > print the row out. > > -- > Rong > > [1]: > https://stackoverflow.com/questions/49380778/how-to-stream-a-json-using-flink > [2]: > https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/table/sourceSinks.html#table-sources-sinks > > On Wed, Feb 6, 2019 at 3:06 AM françois lacombe < > francois.laco...@dcbrain.com> wrote: > >> Hi all, >> >> I currently get a json string from my pgsql source with nested objects to >> be converted into Flink's Row. >> Nested json objects should go in nested Rows. >> An avro schema rules the structure my source should conform to. >> >> According to this json : >> { >> "a":"b", >> "c":"d", >> "e":{ >> "f":"g" >> } >> } >> >> ("b", "d", Row("g")) is expected as a result according to my avro schema. >> >> I wrote a recursive method which iterate over json objects and put nested >> Rows at right indices in their parent but here is what outputs : ("b", "d", >> "g") >> Child Row is appended to the parent. I don't understand why. >> Obviously, process is crashing arguing the top level Row arity doesn't >> match serializers. >> >> Is there some native methods in Flink to achieve that? >> I don't feel so comfortable to have written my own json processor for >> this job. >> >> Do you have any hint which can help please ? >> >> All the best >> >> François >> >> >> >> <http://www.dcbrain.com/> <https://twitter.com/dcbrain_feed?lang=fr> >> <https://www.linkedin.com/company/dcbrain> >> <https://www.youtube.com/channel/UCSJrWPBLQ58fHPN8lP_SEGw> >> >> [image: Arbre vert.jpg] Pensez à la planète, imprimer ce papier que si >> nécessaire >> > -- <http://www.dcbrain.com/> <https://twitter.com/dcbrain_feed?lang=fr> <https://www.linkedin.com/company/dcbrain> <https://www.youtube.com/channel/UCSJrWPBLQ58fHPN8lP_SEGw> Pensez à la planète, imprimer ce papier que si nécessaire