tag:blogger.com,1999:blog-6929422799523574458.post2162267210761938124..comments2023-03-24T11:36:03.468+01:00Comments on Albert Attard: Practical Example of GSONAnonymoushttp://www.blogger.com/profile/05001967782991767837noreply@blogger.comBlogger27125tag:blogger.com,1999:blog-6929422799523574458.post-88638676986764790682013-12-10T13:49:28.379+01:002013-12-10T13:49:28.379+01:00I wish people would write these articles for java ...I wish people would write these articles for java beginners. Leaving out code, no matter how insignificant it may seem to the author may mean the complete misunderstanding for beginners like myselfAnonymoushttps://www.blogger.com/profile/13961417773666731934noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-63017071445165779562013-07-17T12:32:30.018+02:002013-07-17T12:32:30.018+02:00Thank you for noticing.
Please note that both s...Thank you for noticing. <br /><br />Please note that both sites are mine and I'm migrating from this blog to the javacreed.com website. Also, I've added a message that the beginning of this article saying that this page has moved to javacreed.Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-50112913147049708592013-07-16T21:19:10.871+02:002013-07-16T21:19:10.871+02:00I believe JavaCreed has co-opted your blog post. ...I believe JavaCreed has co-opted your blog post. http://www.javacreed.com/simple-gson-example/Danhttps://www.blogger.com/profile/10409938565484540163noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-59802803902606559252012-06-23T08:52:23.103+02:002012-06-23T08:52:23.103+02:00It depends on how the file is structured. I would...It depends on how the file is structured. I would go for custom serielazation. I've added a link in one of the above replies.Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-55972291178425089952012-06-23T08:35:10.166+02:002012-06-23T08:35:10.166+02:00Hi,
Good article. I have a bunch of json objects ...Hi,<br /><br />Good article. I have a bunch of json objects in a file. How do I take care of it. I can email the file if needed.<br /><br />ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-47175072498791162352012-05-11T09:50:31.795+02:002012-05-11T09:50:31.795+02:00I recommend the use of custom deserialization inst...I recommend the use of custom deserialization instead. See the following link for further information about how to do this: <br />https://sites.google.com/site/gson/gson-user-guide#TOC-Custom-Serialization-and-DeserializationAnonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-80653114221343180322012-05-11T01:15:05.974+02:002012-05-11T01:15:05.974+02:00The simpliest to be done in this case is to replac...The simpliest to be done in this case is to replace<br /> "1": { <br /> with <br />"_1": {<br /><br />and create class <br /> public static class EntriesCollection<br /> {<br /> Entry _0;<br /> Entry _1;<br /> Entry _2;<br /> Entry _3;<br /> Entry _4;<br /> Entry _5;<br /> Entry _6;<br /> Entry _7;<br /> }<br />which will be holding values.<br />Other classes may look like this<br /> public static class Entry<br /> {<br /> TermObject OriginalTerm;<br /> TermObject FirstTranslation;<br /> String Note;<br /> }<br /> <br /> public static class TermObject<br /> {<br /> String term;<br /> String POS;<br /> String sense;<br /> String usage;<br /> <br /> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-79389891705223406702012-02-19T22:05:30.645+01:002012-02-19T22:05:30.645+01:00That should not be a problem. A class or a JSON ob...That should not be a problem. A class or a JSON object can have more than one field. What kind of error do you have? Can you paste it here or email it tome at albertattard@gmail.com.Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-56592293635175158872012-02-19T20:33:57.157+01:002012-02-19T20:33:57.157+01:00but, if I had instead of "1", "2&qu...but, if I had instead of "1", "2" etc names like "zero", "one", "two" etc... I'd have always an error, because "PrincipalTranslations" has 3 (or more) sub item...<br /><br />(anyway to solve the problem of number maybe, maybe I could create a parser number --> letter)Peppehttps://www.blogger.com/profile/02432007592826708288noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-47436552146113932852012-02-19T19:56:14.360+01:002012-02-19T19:56:14.360+01:00The field "term" is an object that has t...The field "term" is an object that has the field "PrincipalTranslations". This is an object which has three fields: "zero", "1", and "2". These three are of the same type (object that has two fields: "termine" and "traduzione"). But I think you know this already.<br /><br />Here is your challenge. Variables in Java cannot start with an number, thus you cannot have variables 1 and 2. To go about this problem you need to write your own GSON deserializer. I'm planning to write an article about this hopefully by the end of this week as this is the most popular page in my small blog.<br /><br />Please have a look at the official GSON site: https://sites.google.com/site/gson/gson-user-guide for more information about how you can do this. I will try my best to write an article about that soon. Should you need further help, email me and I will see what I can do.Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-37791968163104026262012-02-19T19:44:31.784+01:002012-02-19T19:44:31.784+01:00Hi, what can I do, if I have a json like this?
{
...Hi, what can I do, if I have a json like this?<br /><br />{<br /> "term" : {<br /> "PrincipalTranslations" : {<br /> "zero" : {<br /> termine:"casa",<br /> traduzione:"home"<br /> }<br /> "1" :{<br /> termine:"testa",<br /> traduzione:"head"<br /> }<br /> "2" :{<br /> termine:"dito",<br /> traduzione:"finger"<br /> }<br /> }<br /> }<br />}Peppehttps://www.blogger.com/profile/02432007592826708288noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-41494223991570349082012-02-17T10:33:27.928+01:002012-02-17T10:33:27.928+01:00Can you please elaborate your question and provide...Can you please elaborate your question and provide an example?Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-42903452661590414562012-02-16T23:41:56.892+01:002012-02-16T23:41:56.892+01:00hello, what does the GSON Java object look like to...hello, what does the GSON Java object look like to ingest a JSON array. is the java object an array or a parametrized list. txAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-35678952137089460632012-02-07T10:51:26.894+01:002012-02-07T10:51:26.894+01:00How come these JSON objects are not returned as an...How come these JSON objects are not returned as an array?Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-2485218995988743522012-02-07T10:33:52.196+01:002012-02-07T10:33:52.196+01:00what if the web service returns more than one obje...what if the web service returns more than one object ?Hichamhttps://www.blogger.com/profile/10946760535588974004noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-7817674744522921572011-12-28T10:58:14.526+01:002011-12-28T10:58:14.526+01:00Do you need to convert a list of objects into JSON...Do you need to convert a list of objects into JSON? Can you provide more information please?Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-52680707309873418462011-12-28T10:47:19.291+01:002011-12-28T10:47:19.291+01:00Hi All,
My scenario is to add list of objects in ...Hi All,<br /><br />My scenario is to add list of objects in Gson object. Can anyone help me out of this.Amaan Alinoreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-14628087525787136752011-07-25T06:10:48.261+02:002011-07-25T06:10:48.261+02:00Good and easy article even for a basic programmer....Good and easy article even for a basic programmer.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-46742724949208894122011-07-05T19:18:23.173+02:002011-07-05T19:18:23.173+02:00Do you mean like a class Generator from a give JSO...Do you mean like a class Generator from a give JSON? If that's your question, I don't know. Google may here you there.Anonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-31104597265133195382011-07-05T19:16:09.666+02:002011-07-05T19:16:09.666+02:00Is there any way to input a JSON structure and spi...Is there any way to input a JSON structure and spit out the equivalent representative JAVA Pojo?William Bathursthttps://www.blogger.com/profile/12486848830663719376noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-61338001911644952622011-07-02T08:37:37.907+02:002011-07-02T08:37:37.907+02:00Good and understandable article about GSon! Thank ...Good and understandable article about GSon! Thank you...<br /><br />Best regards, <br />KaiKai Wähnerhttps://www.blogger.com/profile/17068174875342008383noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-60496528345836839062011-06-17T11:52:30.024+02:002011-06-17T11:52:30.024+02:00Very nice article explaining Gson in simple words....Very nice article explaining Gson in simple words. Indeed Gson is very easy and flexible to use.Udayannoreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-73351207813642044812010-11-03T18:20:37.495+01:002010-11-03T18:20:37.495+01:00Very good.Very good.Iannuzz85noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-46847553965703500022010-04-13T08:09:30.179+02:002010-04-13T08:09:30.179+02:00I'm not sure I follow you, but fields (variabl...I'm not sure I follow you, but fields (variables in general) in Java cannot contain spaces. If you want email me you code and I'll see if I can help you. My email address is albertattard@gmail.comAnonymoushttps://www.blogger.com/profile/05001967782991767837noreply@blogger.comtag:blogger.com,1999:blog-6929422799523574458.post-36387042004917905572010-04-13T00:36:04.016+02:002010-04-13T00:36:04.016+02:00Hi, I am new to this and this post is really helpf...Hi, I am new to this and this post is really helpful. However, what if the field contains a space? (I am trying to convert json to pojo so i am calling fromJson method.Anonymousnoreply@blogger.com