JSON parsing doubt!

My Json text is:

{{"itemLists": ["2"],"user":{"password":"pwd@103","userId":"103","userType":"SUPPLIER","username":"Clark"}}

I wrote json parser such as:

try
{
JSONObject mainouter =
new
JSONObject(result);
JSONArray ja=mainouter.getJSONArray(
"itemLists"
);

if(ja!=null
){

for(int
i=0;i 
         
        

In your example, mainouter includes a table (itemLists) and a JSONObject (user). If you get the JSONObject of mainouter the same way you got the JSONArray and then you can forget everything that is not part of the user of JSONObject. It may be advantageous to give this good reading: http://java.sun.com/developer/technicalArticles/javame/json-me/

Tags: BlackBerry Developers

Similar Questions

  • I get this error message every time I open firefox: "tote: json.parse: unexpected end of data."

    Everytime I open Firefox I get this message "tote: json.parse: unexpected end of data." Otherwise everything works fine, I have not noticed any kind of functionality problems.
    Thanks for the help!

    Note that your list of details of the system shows that you have a user.js file in the profile folder to initialize some preferences at each start of Firefox.

    The user.js file appears only if you or another software created, therefore, normally, he wouldn't be here.
    You should check its contents with a text editor if you do not create this file yourself.

    The user.js file is read whenever you launch Firefox and initializes the preferences to the value specified in this file, so set of preferences via user.js can be changed temporarily for the current session.

  • ATTENTION: nsIJSON.decode is obsolete. Use JSON.parse instead.

    ATTENTION: nsIJSON.decode is obsolete. Use JSON.parse instead. Symptom. WHN I open a new tab, the creen goes on with my screens recorded, but none of them will load.

    Try Firefox Safe mode to see how it works there.

    A way of solving problems, which disables most of the modules.

    (If you use it, switch to the default theme).

    • You can open the mode without failure of Firefox 4.0 + by pressing the SHIFT key when you use the desktop Firefox or shortcut in the start menu.
    • Or use the Help menu option, click restart with the disabled... modules while Firefox is running.

    Do not choose anything at the moment, just use 'continue in safe mode.

    To exit safe mode of Firefox, simply close Firefox and wait a few seconds before using the shortcut of Firefox (without the Shift key) to open it again.

    If it's good in Firefox Safe mode, your problem is probably caused by an extension, and you need to understand that one.

    http://support.Mozilla.com/en-us/KB/troubleshooting+extensions+and+themes

    When find you what is causing that, please let us know. It might help others who have this problem.

  • JSON Parser

    Hi all

    I have a problem with Json parser.

    I have download and insert file lib (as3corelib.swc).

    then I tried to use the code to execute.

    
    http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            initialize="init()">
    
        
            
        
    
        
            
                
                
                
                
            
        
        
        
    
    
    

    Here the error.

    I need to change the data grid? because I want to use list (maybe)

    can any1 tell me with simple json parser?

    Thks b4

    Try to convert your jsonDataArray to an ArrayCollection collection type:

    var arrayCollection:ArrayCollection = new ArrayCollection();

    arrayCollection.source = jsonDataArray;

    dg.dataProvider = arrayCollection collection;

  • JSON Parser very slow

    Hi all

    I use the parser JSON to parse a long string, stored in a text file. The string is a list of cities in the United Kingdom (about 1300 cities). There are approximately 47000 characters. It takes about 10 seconds on a blackberry bold 9700 to create a JSONObject to the chain.

    You guys have any suggestions to improve performance?

    Thank you

    probably not. You can use a thread with min_priority to keep the head etc. UI, but otherwise, you will take your time, or switch to a more efficient like sqllite or similar data model.

  • JSON Parser file path not found

    So I have a JSON file from which I am trying to retrieve data, but I can't get the correct path of the file. I use Unflatten of JSON

    The JSON string looks like this:

    {"latitude":32.78,"longitude":-96.81,"timezone":"America/Chicago","offset":-5,"currently":{"time":1478744444, "summary":"Mostly cloudy"},"minutely":{},"hourly":{"summary":"Rain","icon":"rain","data":[{"time":1478744555,"summary":"Cloudy","temperature":60.55,"windSpeed":14.5}{"time":1478745555,"summary":"Mildly cloudy","temperature":60.00,"windSpeed":13.5}]},"daily":{},"flags":{}}
    

    There is much more in the actual string, but the important part is the hourly data, which are divided into 48 different pieces for 48 hours. I know I can get the 'time' and 'summary' part 'currently', but whenever I try to get something 'all hours' or ' schedule / data "I get this error:" LabVIEW: the path is not found in the JSON string. "

    I can get the info 'currently' like this: it is just to show that the path is very simple, just "currently / hour ' and it works.

    But trying to do the same thing does not work with the array of objects:

    I also tried to make the type and by default is the same as what is in the elements of the array 'features', but the error is still the same.

    So is it possible to separate each of the time slices in the 'data', or to extract what is in the block of 'time' and then use the function JSON Unflatten on it again?

    You must include the array index in your path. The hooks in the json data indicate a table, to do something like the following:

    For some reason, I'm getting a "LabVIEW: the JSON string is not valid." Error in JSON strings must be encoded in UTF - 8 and must conform to the JSON grammar. ", but that might just be because of her copy + paste of the JSON string.

    Oh... missing the comma between the elements of the array. Add a comma after the wind speed':14.5} at the end of the 6th line.

    In your second example, you should have the cluster in an array of clusters containing 3 digital items - while must have worked. It takes a little getting used to understand how to convert JSON structures clustered LV.

  • Scalar JSON parsing of the HTTP Client

    Hello everyone, I have been using the HTTP Client to call an API via HTTP GET to get a JSON string.  I want to be able to analyze all the information and data that I get in this JSON string.  I think that the JSON string I get is a JSON scalar and not an array or an object.  It looks like a combination of table and object.  Here is an example of the data that I'll be back:

    {"Measurements": [{"voltageRMS": 120.12,: 121044.295 ' currentRMS ': 11.85, ' totalEnergy '}], 'code': 'OK', 'time': 7}

    I tried to use "JSON unflatten" but it did not work.  I continued to get several errors.  Error 1 was that this path not found in JSON when I put in currentRMS as a string table in the way even though I am following the directions for help.  Error 2, is that I have a different type of data between JSON and LabView.  In one of the LabView examples, it is an array JSON goes to several unflatten JSON and it works fine (as long as it's a JSON array).  However, once I use my JSON scalar, the JSON unflatten function no longer works.

    So, I downloaded some addons and used the JSON API in the LAVA.  I used the JSON API for scalar but kept on getting errors.  One of these errors is that the vi is unable to analyze the data.  I tried with several vi analysis (i.e. timestamp).  I tried to use the JSON array and thus got errors.

    Any advice would be greatly appreciated, I'm completely stuck.  Help, please.  Thank you.

    Even if you have only 1 point in the array, the field of 'measures' is a JSON array - noted in square brackets. Don't forget - the cluster should match the JSON data structure you are trying to decode exactly (not the format you expect!).

    With JSON Unflatten - you can either convert the entire string JSON, or you can draw the elements individually on the way (for example, an XPath in XML).

    Here are some examples:

    In the top example - I unflatten the entire cluster and this will give an array of measures. In the second example, I only remove the "0th" of the measure as a scalar array. Had not added the '0' in the path of the table, the data type / output would have been an array of measures.

  • JSON parsing in os 5

    Hi, I'm new to json analysis and I'm working on 5 os. and I using the org.json.me library in my project.
    I had the chain reaction, I'll post my json response I receive.

     try {
                ConnectJson connectJson = new ConnectJson();
                connectJson.jsonResult("..................");// URL
                //LabelField jsonResult = new LabelField(connectJson.response);
                //System.out.println("------- "+connectJson.response);
                jsonresponse = ""+connectJson.response;
                System.out.println("\n------- "+jsonresponse);
                //add(jsonResult);
    
            } catch (Exception e) {
                // TODO Auto-generated catch block
                System.out.println("errr "+e.toString());
            }
    
    ConnectJson.java  class
    
    public class ConnectJson extends Thread {
    
         private String url;
         public String response;
         private String myinterface = ";interface=wifi";
    
          public void run() {
                 HttpConnection conn = null;
                 InputStream in = null;
                 int code;
    
           try {
              conn = (HttpConnection) Connector.open(this.url , Connector.READ);
                 conn.setRequestMethod(HttpConnection.GET);
                 code = conn.getResponseCode();
    
                 if (code == HttpConnection.HTTP_OK) {
                     in = conn.openInputStream();
                     ByteArrayOutputStream out = new ByteArrayOutputStream();
    
                     byte[] buffer = new byte[in.available()];
                     int len = 0;
    
                     while (-1 != (len = in.read(buffer))) {
                         out.write(buffer);
                     }
    
                     out.flush();
                     this.response = new String(out.toByteArray());
    
                     if (out != null){
                         out.close();
                     }
                     if (in != null){
                         in.close();
                     }
                     if (conn != null){
                         conn.close();
                     }
                 }else{
                     System.out.println("erorrrrrrrr");
                 }
    
             } catch (Exception e) {
                //Dialog.inform(e.toString());
                System.out.println(e.toString());
             }
        }
    

    Here is the result that I am.

    [["183","BJP State President Sanjay Tandon's visit to Amita Shukla's Home"," BJP President C[0.0] handigarh Sanjay Tandon at Amita Shukla's Home","2013-01-04","04-01-2013---01.jpg","Amita Shukla,Mee[0.0] ting BJP,"],["184","Sanjay Tandon at mahasamadhi of Sat[0.0] ya Shri Sai baba.","BJP Chandigarh President, Sanjay Tandon mahasmadhi of Sri Satya Sai Baba.(Andhra[0.0]  Pradesh)","2013-01-13","13-01-2013---01.jpg","Satya Shri Sai Baba,Andhra Pradesh Visit,"]]
    

    now how can I Prase, there are two tables?

    you call http://www.blackberry.com/developers/docs/7.1.0api/org/json/me/JSONArray.html#getJSONArray (int) on the index 0 and 1, in this case, to get the Sub-tables.
    and so on until call you getJSONObject to get a single item.

  • JSON parsing

    Hi all

    I get the folowing output string

    ["ME1235NM"]
    
    I have json lib. but i dont know how to get this result as string  from that Json lib. Can any one give the solution for this thing!!
    

    Have you checked the before mentioned link?

    Code example: retrieve a web page by using the network API

  • GET request gives me tab "syntax error: JSON.parse" in response

    Screenshot: http://grab.by/z7zW

    Chrome, postman, curl, everything works fine, just firefox shows me this question

    The problem I had was a cross-domain issue, I didn't notice that my direct reload of Growl was a 'overload' different my node.js server, it's pretty obvious to understand chrome because it show me exactly what the error was, but Firefox just show me that without more information.

  • Child parsing JSON with datasource and view in listview

    Hi, I use datasource to get json from url data and I want in the listview, but json data have child, so I don't know how to access.

    My data source code here:

    DataSource {
            id: serviceDataSource
            source: "http://services.okezone.com/json/headline"
            type: DataSourceType.Json
            onDataLoaded: {
                serviceDataModel.clear();
                serviceDataModel.insertList(data)
            }
        }
    

    And here my display list code:

    ListView {
              dataModel: serviceDataModel
              listItemComponents: [
    
                   ListItemComponent {
                          type: "news"
                          ServiceDetail {
                                 title: ListItemData.title
                                 pubDate: ListItemData.published
                          }
                   }
              ]
     }
    

    And here is the response from json to this url:

    [
    
    {
    
      "okezone": {
    
         "version": "0.1",
    
         "headline": {
    
            "request": {
    
               "channel": 0,
    
               "start": 0
    
            },
    
            "status": "OK",
    
            "more": {
    
               "offset": 2,
    
               "start": 0,
    
               "total": 2
    
            },
    
            "news": {
    
               "type": "2",
    
               "id": "796135",
    
               "channel": {
    
                  "id": "519",
    
                  "label": "Surabaya"
    
               },
    
               "published": "2013-04-23 13:21:25",
    
               "title": "Gara-Gara UN, Mendikbud Didesak Mundur",
    
               "summary": "Para orangtua murid menilai, Mendikbud, Muhammad Nuh, harus bertanggung jawab di balik kesemerawutan sistem dan pelaksanaan Ujian Nasional.",
    
               "thumbnail": "http://img.okeinfo.net/images-data/content/2013/04/23/519/796135/BkuPxui4gB.jpg",
    
               "url": "http://services.okezone.com/json/detail/2013/04/23/519/796135"
    
            }
    
         }
    
      }
    
    }
    ]
    

    Thanks for your help, I do it in two days and does not work.

    Hello

    Try this code

    import bb.cascades 1.0
    import bb.data 1.0
    
    Page {
        content: Container {
            Label {
                text: "List View with json parsing"
            }
    
            ListView {
                id: listViewDemo
                dataModel: GroupDataModel {
                    grouping: ItemGrouping.None
                }
    
                listItemComponents: [
                    ListItemComponent {
                        type: "listItem"
                        StandardListItem {
                            title: ListItemData.okezone.headline.news["title"]
                        }
                    }
                ]
    
                function itemType(data, indexPath) {
                    return "listItem";
                }
            }
        }
    
        attachedObjects: [
            DataSource {
                id: serviceDataSource
                source: "http://services.okezone.com/json/headline"
                type: DataSourceType.Json
                onDataLoaded: {
                    listViewDemo.dataModel.clear();
                    listViewDemo.dataModel.insertList(data)
                }
            }
        ]
    
        onCreationCompleted: {
            serviceDataSource.load();
        }
    }
    

    Don't forget to add the library to .pro file

    LIBS +=-lbbdata

  • Cannot use JsonDataAccess to load the json

    I have the Json file

    [
    {"param":"earfree/earfree","value":true},
    {"param":"earfree/smart_mode","value":true},
    {"param":"earfree/vb_ledcolor_index","value":fales},
    {"param":"earfree/vb_ledcolor_value","value":true},
    {"param":"earfree/vb_remote_accept","value":true},
    {"param":"earfree/vb_remote_reject","value":true},
    {"param":"earfree/vb_remote_failed","value":true},
    {"param":"earfree/callend_alert","value":true},
    {"param":"earfree/vb_accept","value":false},
    {"param":"earfree/vb_reject","value":false}
    ]
    

    I have this code

      JsonDataAccess jda; QVariant list = jda.load("app/native/assets/models/defaultsettings.json");
    
     if (jda.hasError()) { DataAccessError error = jda.error(); qDebug() << "JSON loading error: " << error.errorType() << ": " << error.errorMessage();// return; } else { qDebug() << "JSON loading ok";  JsonDataAccess jda;
        QVariant list = jda.load("app/native/assets/models/defaultsettings.json");
    
        if (jda.hasError())
        {
            DataAccessError error = jda.error();
            qDebug() << "JSON loading error: " << error.errorType() << ": " << error.errorMessage();
        }
        else
        {
            qDebug() << "JSON loading ok";}
    

    ("When I run mode debugging to QVariant list = jda.load("app/native/assets/models/defaultsettings.json ");
    I had this error on the console: ' Python Exception no "QMetaType" symbol in the current environment.:

    And on the table of Variables, the value 'list'

    "Error list: several errors reported." "------cannot run the MI command: - var - create - * error message list of debugger backend: cannot instantiate printer to default visualizer\ cannot create the variable object\ cannot run the MI command: - var - create - * error message list of debugger backend: failed to instantiate printer for default visualizer"

    Please help me.

    Thank you!

    A quick copy paste your JSON in a validator online JSON parser/pointing to typo in one of your 'false' value, you wrote fasle instead.

    https://postimg.org/image/809nbgbot/

  • Does everything with JSON of QML

    Hello

    Just trying to decide what type of template to use for the list, I wanted to do.

    It's true that I can't fully implement JSON in its entirety in QML? that is sort of the key (and everything else 100%) in QML, no C++ at all. (I have a JSON file I created)

    In the examples I see, to do a minimum implementation in C++ and more QML.

    Otherwise, I can use XML purely in QML but will not get the features of sort etc..

    Is everything is OK?

    I just noticed tonight that the 'global' Javascript object, in the environment of waterfalls QML, has a JSON object in it.

    This seems to be the JSON object standard ECMAscript 5 which is documented here: https://developer.mozilla.org/en-US/docs/Using_native_JSON

    By using it, you could make JSON.parse (somestring) and retrieve the result of the analysis of the JSON.  Similar to eval(), but probably better...

    Also a JSON.stringify () has to go the other way.

    These things were probably obvious to many who read this... was good news for me.

  • How to show my listview QML this JSON webservice

    Hi all

    IM new developer for blackberry 10

    It's my first project of construction of a PSA

    I want to ask

    1. This is my JSON www.rws.rajaspot.com/rs_promoclient.php

    2. I want to do a listview in my QML using this JSON

    y at - it a code for this example, I tried to make the market http://stackoverflow.com/questions/18598886/how-to-use-json-webservice-in-blackberry-cascades and http://stackoverflow.com/questions/18638067/how-to-create-listview-for-json-parsing-in-blackberry-ca... but still get error

    Please help, thanks

    Did you add this line to your .pro file...

    LIBS +=-lbbdata

  • JsonDataAccess error in JSON even report it is valid

    I have a problem with parsing JSON which I get from QNetworkReply. I checked on http://json.parser.online.fr/beta/ if json is valid and it is:

    {
        "status": 0,
        "objects": [{
            "id": "i_53909cc3eeafd",
            "name": "picture1",
            "location": [{
                "x": -5,
                "y": 126
            }, {
                "x": 266,
                "y": 126
            }, {
                "x": 269,
                "y": 396
            }, {
                "x": -5,
                "y": 400
            }]
        }]
    }
    

    I use following code:

    void ApplicationUI::onRequestFinished(QNetworkReply* reply) {
    
        QString response = QString::fromUtf8(reply->readAll());
    
        if(reply){
            if(reply->error() == QNetworkReply::NoError) {
    
                JsonDataAccess jsonDataAccess;
                QVariant list = jsonDataAccess.loadFromBuffer(response);
                if (jsonDataAccess.hasError()) {
                    DataAccessError error = jsonDataAccess.error();
                    qDebug() << "JSON loading error: " << error.errorType() << ": " << error.errorMessage();
                    return;
                }
            } else {
                qDebug() << "Network error!";
            }
        }
    
    reply->deleteLater();
    }
    

    Everyt time I receive reply jsonDataAccess shows me error:

    JSON loading error:  3 :  "* Line 1, Column 1
      Syntax error: value, object or array expected.
    "
    

    The second problem is the fact that I am not able to access the values of this json response. I tried many possibilities and I always get empty results.

    OK, the problem is now resolved. I realized that my QNetworkAccessManager I had after the line:

    request.setRawHeader(QString("Accept-Encoding").toAscii(), QString("gzip,deflate").toAscii());
    

    Who was raping my JSON.

Maybe you are looking for

  • No email with my address inMail iCloud

    My iMac does not work with iCloud Mail to Mac Mail. I get the error message "unable to connect to iCloud due to a problem with" THE Email Address (MY) " No problem on my iPhone or on iCloud himself. Somehow, it doesn't recognize my e-mail address. Ca

  • Satellite U200-112: switching between monitors

    Satellite U200-112. To the passage of the mobile display on the external monitor, the resolution is exposed to the display, instead of the external display. Who faced such a problem?

  • Is Satellite A100-233 does support Bluetooth?

    HelloI have the Satellite A100-233. Can I establish internal bluetooth adapter in this model? Thank you

  • ThinkPad 10 support and quality control issues: Moderator/Support, help please

    Please ignore, or even support/moderator - I don't want to waste your time Hello I got a Thinkpad Tablet 10 Thursday directly from China. The Tablet has a manufacturing defect. There is a piece of land under the layer of glass/digitizer, but higher o

  • can not play games

    I was able to play games on IE8 so far.Games open upward, but when you press the Start button, it freezes, says that ie8 is not responding.IE8 works very well except for the games. (no other problems)I tried to games on MSN and Suddenlink home pages.