how to deserialize the serialize json data in android












-1















how to deserialize from the following data.i used Gson lib to parase the data using Serializable. response to parse the data using replace command to remove the ''and parse it.




"[{"ALERT_IND":null,"ACTION_TY_NM":"Face to

Face","A_IND":2.0,"Act_Cat":"R

","ACT_SUB":"Meeting","Status":1.0,"SAG_NM":null,"PRI_TXT":"Medium ","DISPLAY_BACK_CLR":"#000080","OG_SHRT_NM":"Delhi
","OG_NM":"New

Delhi","EMP_NM":"Mannil","CONT_NM":"Kamakhya
Delhi","TO_DT":"29/09/2018","TIME":"08:47","MAST_DATA_TXT":null,"OG_ID":11.0,"C_DT":null,"CONT_ID":1129.0,"LeadOppoId":null,"CITY_NM":"","MOBILE":""}}]"




but some times its not working when using replace command to parse.Any specific lib is available in android. can u help me how to parse the data?
Can u share some code?










share|improve this question



























    -1















    how to deserialize from the following data.i used Gson lib to parase the data using Serializable. response to parse the data using replace command to remove the ''and parse it.




    "[{"ALERT_IND":null,"ACTION_TY_NM":"Face to

    Face","A_IND":2.0,"Act_Cat":"R

    ","ACT_SUB":"Meeting","Status":1.0,"SAG_NM":null,"PRI_TXT":"Medium ","DISPLAY_BACK_CLR":"#000080","OG_SHRT_NM":"Delhi
    ","OG_NM":"New

    Delhi","EMP_NM":"Mannil","CONT_NM":"Kamakhya
    Delhi","TO_DT":"29/09/2018","TIME":"08:47","MAST_DATA_TXT":null,"OG_ID":11.0,"C_DT":null,"CONT_ID":1129.0,"LeadOppoId":null,"CITY_NM":"","MOBILE":""}}]"




    but some times its not working when using replace command to parse.Any specific lib is available in android. can u help me how to parse the data?
    Can u share some code?










    share|improve this question

























      -1












      -1








      -1


      1






      how to deserialize from the following data.i used Gson lib to parase the data using Serializable. response to parse the data using replace command to remove the ''and parse it.




      "[{"ALERT_IND":null,"ACTION_TY_NM":"Face to

      Face","A_IND":2.0,"Act_Cat":"R

      ","ACT_SUB":"Meeting","Status":1.0,"SAG_NM":null,"PRI_TXT":"Medium ","DISPLAY_BACK_CLR":"#000080","OG_SHRT_NM":"Delhi
      ","OG_NM":"New

      Delhi","EMP_NM":"Mannil","CONT_NM":"Kamakhya
      Delhi","TO_DT":"29/09/2018","TIME":"08:47","MAST_DATA_TXT":null,"OG_ID":11.0,"C_DT":null,"CONT_ID":1129.0,"LeadOppoId":null,"CITY_NM":"","MOBILE":""}}]"




      but some times its not working when using replace command to parse.Any specific lib is available in android. can u help me how to parse the data?
      Can u share some code?










      share|improve this question














      how to deserialize from the following data.i used Gson lib to parase the data using Serializable. response to parse the data using replace command to remove the ''and parse it.




      "[{"ALERT_IND":null,"ACTION_TY_NM":"Face to

      Face","A_IND":2.0,"Act_Cat":"R

      ","ACT_SUB":"Meeting","Status":1.0,"SAG_NM":null,"PRI_TXT":"Medium ","DISPLAY_BACK_CLR":"#000080","OG_SHRT_NM":"Delhi
      ","OG_NM":"New

      Delhi","EMP_NM":"Mannil","CONT_NM":"Kamakhya
      Delhi","TO_DT":"29/09/2018","TIME":"08:47","MAST_DATA_TXT":null,"OG_ID":11.0,"C_DT":null,"CONT_ID":1129.0,"LeadOppoId":null,"CITY_NM":"","MOBILE":""}}]"




      but some times its not working when using replace command to parse.Any specific lib is available in android. can u help me how to parse the data?
      Can u share some code?







      java android arrays json api






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 6:58









      kumarkumar

      154




      154
























          3 Answers
          3






          active

          oldest

          votes


















          1














          You can use the Gson library for that.



          Serialization is as simple as calling



          new Gson().toJson(obj)


          And for deserialization,



          new Gson().fromJson(jsonStr, MyClass.class);





          share|improve this answer
























          • after i get response use replace command to remove the and than parse the string to gson . i already implemented this logic .my question is a any lib available in android.

            – kumar
            Nov 26 '18 at 4:25



















          0














          First of all your json string is not a valid json. Because it is ending with an extra closing "}" curly bracket, remove it and then just replace in your json string "" with empty string "".



          jsonString.replace("\", "");


          And then you can parse it using Gson using a model class with serialized keys on fields.



          public class Sample{

          @SerializedName("ALERT_IND")
          private String mAlertInd;

          public void setAlertInd(String alertInd){
          mAlertInd = alertInd;
          }

          public String getAlertInd(){
          return mAlertInd;
          }
          }





          share|improve this answer
























          • i done like this only. my doubt any lib available in android to replace (\ ) and return valid json

            – kumar
            Nov 26 '18 at 4:17



















          0














          you can use JSONObject and JSONArray that it creates a JSON object and you can get elements by key or index



          new JSONObject(jsonString)


          you can use GSON or LoganSquare tools that it parses JSON to a Model that you can get elements by fields name (pay attention to add dependencies before use it)



          new Gson().fromJson(jsonString, Model.class)

          LoganSquare.parse(jsonString, Model.class)


          if you are encoded JSON string that means your string has a backslash before each quotation you can decode to raw string



          String rawJson = str.replaceAll("\\", "");





          share|improve this answer


























          • with out removing the new Gson().fromJson(jsonString, Model.class) not working

            – kumar
            Nov 26 '18 at 4:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53465357%2fhow-to-deserialize-the-serialize-json-data-in-android%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You can use the Gson library for that.



          Serialization is as simple as calling



          new Gson().toJson(obj)


          And for deserialization,



          new Gson().fromJson(jsonStr, MyClass.class);





          share|improve this answer
























          • after i get response use replace command to remove the and than parse the string to gson . i already implemented this logic .my question is a any lib available in android.

            – kumar
            Nov 26 '18 at 4:25
















          1














          You can use the Gson library for that.



          Serialization is as simple as calling



          new Gson().toJson(obj)


          And for deserialization,



          new Gson().fromJson(jsonStr, MyClass.class);





          share|improve this answer
























          • after i get response use replace command to remove the and than parse the string to gson . i already implemented this logic .my question is a any lib available in android.

            – kumar
            Nov 26 '18 at 4:25














          1












          1








          1







          You can use the Gson library for that.



          Serialization is as simple as calling



          new Gson().toJson(obj)


          And for deserialization,



          new Gson().fromJson(jsonStr, MyClass.class);





          share|improve this answer













          You can use the Gson library for that.



          Serialization is as simple as calling



          new Gson().toJson(obj)


          And for deserialization,



          new Gson().fromJson(jsonStr, MyClass.class);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 7:05









          Gourango SutradharGourango Sutradhar

          24418




          24418













          • after i get response use replace command to remove the and than parse the string to gson . i already implemented this logic .my question is a any lib available in android.

            – kumar
            Nov 26 '18 at 4:25



















          • after i get response use replace command to remove the and than parse the string to gson . i already implemented this logic .my question is a any lib available in android.

            – kumar
            Nov 26 '18 at 4:25

















          after i get response use replace command to remove the and than parse the string to gson . i already implemented this logic .my question is a any lib available in android.

          – kumar
          Nov 26 '18 at 4:25





          after i get response use replace command to remove the and than parse the string to gson . i already implemented this logic .my question is a any lib available in android.

          – kumar
          Nov 26 '18 at 4:25













          0














          First of all your json string is not a valid json. Because it is ending with an extra closing "}" curly bracket, remove it and then just replace in your json string "" with empty string "".



          jsonString.replace("\", "");


          And then you can parse it using Gson using a model class with serialized keys on fields.



          public class Sample{

          @SerializedName("ALERT_IND")
          private String mAlertInd;

          public void setAlertInd(String alertInd){
          mAlertInd = alertInd;
          }

          public String getAlertInd(){
          return mAlertInd;
          }
          }





          share|improve this answer
























          • i done like this only. my doubt any lib available in android to replace (\ ) and return valid json

            – kumar
            Nov 26 '18 at 4:17
















          0














          First of all your json string is not a valid json. Because it is ending with an extra closing "}" curly bracket, remove it and then just replace in your json string "" with empty string "".



          jsonString.replace("\", "");


          And then you can parse it using Gson using a model class with serialized keys on fields.



          public class Sample{

          @SerializedName("ALERT_IND")
          private String mAlertInd;

          public void setAlertInd(String alertInd){
          mAlertInd = alertInd;
          }

          public String getAlertInd(){
          return mAlertInd;
          }
          }





          share|improve this answer
























          • i done like this only. my doubt any lib available in android to replace (\ ) and return valid json

            – kumar
            Nov 26 '18 at 4:17














          0












          0








          0







          First of all your json string is not a valid json. Because it is ending with an extra closing "}" curly bracket, remove it and then just replace in your json string "" with empty string "".



          jsonString.replace("\", "");


          And then you can parse it using Gson using a model class with serialized keys on fields.



          public class Sample{

          @SerializedName("ALERT_IND")
          private String mAlertInd;

          public void setAlertInd(String alertInd){
          mAlertInd = alertInd;
          }

          public String getAlertInd(){
          return mAlertInd;
          }
          }





          share|improve this answer













          First of all your json string is not a valid json. Because it is ending with an extra closing "}" curly bracket, remove it and then just replace in your json string "" with empty string "".



          jsonString.replace("\", "");


          And then you can parse it using Gson using a model class with serialized keys on fields.



          public class Sample{

          @SerializedName("ALERT_IND")
          private String mAlertInd;

          public void setAlertInd(String alertInd){
          mAlertInd = alertInd;
          }

          public String getAlertInd(){
          return mAlertInd;
          }
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 7:32









          Muhammad NoorMuhammad Noor

          11




          11













          • i done like this only. my doubt any lib available in android to replace (\ ) and return valid json

            – kumar
            Nov 26 '18 at 4:17



















          • i done like this only. my doubt any lib available in android to replace (\ ) and return valid json

            – kumar
            Nov 26 '18 at 4:17

















          i done like this only. my doubt any lib available in android to replace (\ ) and return valid json

          – kumar
          Nov 26 '18 at 4:17





          i done like this only. my doubt any lib available in android to replace (\ ) and return valid json

          – kumar
          Nov 26 '18 at 4:17











          0














          you can use JSONObject and JSONArray that it creates a JSON object and you can get elements by key or index



          new JSONObject(jsonString)


          you can use GSON or LoganSquare tools that it parses JSON to a Model that you can get elements by fields name (pay attention to add dependencies before use it)



          new Gson().fromJson(jsonString, Model.class)

          LoganSquare.parse(jsonString, Model.class)


          if you are encoded JSON string that means your string has a backslash before each quotation you can decode to raw string



          String rawJson = str.replaceAll("\\", "");





          share|improve this answer


























          • with out removing the new Gson().fromJson(jsonString, Model.class) not working

            – kumar
            Nov 26 '18 at 4:19
















          0














          you can use JSONObject and JSONArray that it creates a JSON object and you can get elements by key or index



          new JSONObject(jsonString)


          you can use GSON or LoganSquare tools that it parses JSON to a Model that you can get elements by fields name (pay attention to add dependencies before use it)



          new Gson().fromJson(jsonString, Model.class)

          LoganSquare.parse(jsonString, Model.class)


          if you are encoded JSON string that means your string has a backslash before each quotation you can decode to raw string



          String rawJson = str.replaceAll("\\", "");





          share|improve this answer


























          • with out removing the new Gson().fromJson(jsonString, Model.class) not working

            – kumar
            Nov 26 '18 at 4:19














          0












          0








          0







          you can use JSONObject and JSONArray that it creates a JSON object and you can get elements by key or index



          new JSONObject(jsonString)


          you can use GSON or LoganSquare tools that it parses JSON to a Model that you can get elements by fields name (pay attention to add dependencies before use it)



          new Gson().fromJson(jsonString, Model.class)

          LoganSquare.parse(jsonString, Model.class)


          if you are encoded JSON string that means your string has a backslash before each quotation you can decode to raw string



          String rawJson = str.replaceAll("\\", "");





          share|improve this answer















          you can use JSONObject and JSONArray that it creates a JSON object and you can get elements by key or index



          new JSONObject(jsonString)


          you can use GSON or LoganSquare tools that it parses JSON to a Model that you can get elements by fields name (pay attention to add dependencies before use it)



          new Gson().fromJson(jsonString, Model.class)

          LoganSquare.parse(jsonString, Model.class)


          if you are encoded JSON string that means your string has a backslash before each quotation you can decode to raw string



          String rawJson = str.replaceAll("\\", "");






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 26 '18 at 7:16

























          answered Nov 25 '18 at 7:32









          saeedatasaeedata

          44126




          44126













          • with out removing the new Gson().fromJson(jsonString, Model.class) not working

            – kumar
            Nov 26 '18 at 4:19



















          • with out removing the new Gson().fromJson(jsonString, Model.class) not working

            – kumar
            Nov 26 '18 at 4:19

















          with out removing the new Gson().fromJson(jsonString, Model.class) not working

          – kumar
          Nov 26 '18 at 4:19





          with out removing the new Gson().fromJson(jsonString, Model.class) not working

          – kumar
          Nov 26 '18 at 4:19


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53465357%2fhow-to-deserialize-the-serialize-json-data-in-android%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Futebolista

          Feedback on college project

          Albești (Vaslui)