Hi, help make simple deserialization, what's the mistake?

public class MainActivity extends AppCompatActivity { private final String TAG = "LOL"; String jsons = "{'appname':'application', 'Version':'0.1.0', 'UUID':'300V', 'WWXY':'310W', 'ABCD':'270B', 'YUDE':'280T'}"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Gson gson = new GsonBuilder().create(); MainActivity mainActivity = gson.fromJson(jsons, MainActivity.class); Log.i(TAG, "MSG " + mainActivity); } } 
  • No need to ask the same question - edit the old one - YuriySPb
  • That way you have 2 questions for one problem and both are incomplete - in one error logs, and in the other - a code. - YurySPb
  • one
    @ YuriiSPb as far as it could have filled: As-and-than-parsit-json-per-java .... 9 options and a reference plate So what can help in the future Alexey Shimansky
  • @ Alexey Shimansky, cool! Plus everything is there) - YuriySPb

1 answer 1

Create a model class for json and parse it in this model:

 public class MyPojo { public String WWXY; public String appname; public String YUDE; public String UUID; public String ABCD; public String Version; } 
 Gson gson = new GsonBuilder().create(); MyPojo data = gson.fromJson(jsons, MyPojo.class); 

More information about parsing JSON here - How and what to parse Json in Java?