I need a PARSER for Android

0 votes
I use Android and Eclipse ..

So i get the result back in JSON in a String variable in Eclipse - Java.

 

Whats the best Parser to use and do you have any example code you can point me to ?

 

Thanks ...
related to an answer for: Best JSON parser you recommend
asked May 20, 2015 in App42 Cloud API-BaaS by jingahr (31 points)

1 Answer

+1 vote

Hi Jingahr,

You can easily fetch specific key from App42 using Storage API. Please refer following code snippet, that will help you in parsing.

public static void loadApp42Contacts1() {
        App42API.initialize("ANDROID_APPLICATION_CONTEXT","API_KEY","SECRET_KEY");  
        StorageService storageService=App42API.buildStorageService();
        Set<String> selectKeys = new HashSet<String>();  
        selectKeys.add("Key");  
        storageService.setSelectKeys(selectKeys);   
        storageService.findAllDocuments("YourDBName",
                "YourCollectionName", new App42CallBack() {

                    @Override
                    public void onSuccess(Object arg0) {
                        // TODO Auto-generated method stub
                        parseData(((Storage) arg0)
                                .getJsonDocList());
                    }

                    @Override
                    public void onException(Exception arg0) {
                        // TODO Auto-generated method stub
                        
                    }
                });
    }
    
    private static void parseData(ArrayList<JSONDocument> jsonDocList){
        for(JSONDocument userJsonDoc:jsonDocList){
            try {
                JSONObject jsonData=new JSONObject(userJsonDoc.jsonDoc);
                System.out.println(jsonData.toString());
                System.out.println(jsonData.opt("Key"));
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

Let me know if it helps.

 

Thanks

Vishnu Garg

 

answered May 20, 2015 by Vishnu Garg (674 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...