Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580949

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:03:11+00:00 2026-05-30T18:03:11+00:00

i am developing app in blackberry version 5.0, and i had import all library

  • 0

i am developing app in blackberry version 5.0, and i had import all library which require for json in 5.0.

i had download library from this url
http://supportforums.blackberry.com/t5/Java-Development/JSON-library/td-p/573687

even i not getting response, what i had miss in this code please help me.

Below is my code For json parsing.

 package mypackage;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;

import JSON_ME_Library.src.org.json.me.JSONArray;
import JSON_ME_Library.src.org.json.me.JSONException;
import JSON_ME_Library.src.org.json.me.JSONObject;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;


public final class MyScreen extends MainScreen
{

    String url="http://www.appymail.com/iphone-messenger/456842/";

    public MyScreen()
    {                
        setTitle("Json Parsing Sample");

         String aa=jsonresponse(url);

        if(aa.equalsIgnoreCase(""))
        {
            add(new LabelField("NO res"));
        }
        else
        {
            parseJSONResponceInBB(aa);

        }


    }



    void parseJSONResponceInBB(String jsonInStrFormat)
    {  


        try {  
            JSONObject json = new JSONObject(jsonInStrFormat);  
            JSONArray jArray= json.getJSONArray("messages");  

            //JSONArray arr=jArray.getJSONArray(0);

            for(int i=0;i<jArray.length();i++)
            {  
                JSONObject j = jArray.getJSONObject(i);  
                String from = j.getString("id");         
                add(new LabelField("id=="+from));

                String to =j.getString("title");
                add(new LabelField("title=="+to));           

                String message=j.getString("body");                
                add(new LabelField("Body=="+message));

            }  
        } catch (JSONException e) 
        {           
            e.printStackTrace();  
        }    



    }  

    public static String jsonresponse (String url) 
    { 
        String response = null; 
        HttpConnection httpConnection = null; 
        InputStream inStream = null; 
        int code; 
        StringBuffer stringBuffer = new StringBuffer();

        try { 

            httpConnection = (HttpConnection) Connector.open(url, Connector.READ); 
            httpConnection.setRequestMethod(HttpConnection.GET); 

            code = httpConnection.getResponseCode(); 

            if(code == HttpConnection.HTTP_OK) 
            { 
                inStream=httpConnection.openInputStream(); 
                int c; 


                while((c=inStream.read())!=-1) 
                { 
                  stringBuffer.append((char)c); 
                } 
                response=stringBuffer.toString(); 
                System.out.println("Response Getting from Server is ================" + response); 



            }
        else 
            { 
                UiApplication.getUiApplication().invokeLater(new Runnable() 
                { 

                    public void run()
                    {       
                        Dialog.inform("Connection error"); 
                    } 
                }); 
            } 


        } 
        catch (Exception e) 
        { 

            System.out.println("caught exception in jsonResponse method"+e.getMessage()); 

        } 
        finally
        {

        //      if (outputStream != null) 
        //      { 
        //          outputStream.close(); 
        //      }
                if (inStream != null) 
                { 
                    try {
                        inStream.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } 
                }
                if (httpConnection != null ) 
                { 
                    try {
                        httpConnection.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } 
                } 
        }

        return response; 
    }


}
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Related Questions

i am developing app in blackberry version 5.0, and i had import all library
I am looking into developing a small app to run on a blackberry which
i am developing app in Blackberry which have GPS Functionality. so first i want
Am developing an app, which first gets the current date from DatePicker using Calendar.getInstance(),
I'm developing a Java app for blackberry, in this app I have a login
I'm developing a BlackBerry app which uses an embedded browser to display html content.
Hi I am developing app which downloads the images from the web site and
I'm considering developing an app for Google App Engine, which should not get too
When developing a blackberry app originally, I didn't pay much attention to being able
I am developing a blackberry app and I am new to Blackberry. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.