MAF: Using rest with JSON

Hi all

I use jdev 12.1.3

While practicing the CRG, I am facing a problem with the help of rest with JSON response.

I followed this: https://blogs.oracle.com/adf/entry/simple_get_operation_with_json

A slight difference is that I already have a Restful services with JSON response I have hace created in Oracle Apex.

Following the example, I followed the steps but when I open the application in the Android emulator after deployment, I don't get all the lines, I dropped the data as MAF List View control.

I don't get all the lines and I am showing 0 in the first row.

Please let me know what could be the problem.

Kind regards

KP

See your json output you can't edit it directly to the employee object.

First you must get the json object, then json for the elements array, then one by one, you must create the Employee object.

In addition, you see 0 because for a PGE no integer, the default value is 0 because the data are not filled the json output.

Try the code below and your question should get solved:

answer = restServiceAdapter.send("");

JSONObject jsonObj = new JSONObject (response);

JSONArray empList = (JSONArray) jsonObj.get ('items');

int size = empList.length ();

ArrayList empArray = new ArrayList();

for (int i = 0; i)

try {}

Employee emp = new Employee();

JSONObject result = empList.getJSONObject (i);

String empno = (String) result.get ("empno");

Ename string = (String) result.get ("ename");

emp.setEmpno (Integer.parseString (empno));

emp.setEname (ename);

empArray.add (emp);

} catch (System.Exception e)

{}

Employee [] e = (Employee []) empArray.toArray (New Employee [empArray.size ()]);

e return;

Your method signature must be:

public employee [] fetchEmpDetails()

With the signature above you return an employee table which can be used for a list view.

Let me know if it helps.

Kind regards

Deepak

Tags: Oracle Mobile

Similar Questions

  • MAF and REST

    Does anyone know the requirements and limits for the RESTServiceAdapter?

    I spent the last day or so to study different options and seem to have reduced in the absence of Content-Length in the response, or maybe connection: close

    For example, a REST service that works returns the following raw http response

    HTTP/1.1 200 OK

    Access-Control-Allow-Origin: *.

    Content-Type: application/json

    Date: Tuesday, July 22, 2014 10:48:27 GMT

    Content-Length: 225

    {'ip': '122.109.131.63', 'country_code': "to THE", "country_name": "Australia", "region_code": "05", "region_name": 'South Australia', 'city': 'Adelaide', 'postal code': latitude '',' ':-34.0287, "longitude": 138.0986, ' metro_code ': '',' area_code' ":" "}

    Conversely, a REST service that does not work will return the following raw http response

    HTTP/1.1 200 OK

    Date: Tuesday, July 22, 2014 10:56:02 GMT

    Server:

    Connection: close

    Host: 192.168.0.4:8080

    Content-Type: application/json

    {'ip': '122.109.131.63', 'country_code': "to THE", "country_name": "Australia", "region_code": "05", "region_name": 'South Australia', 'city': 'Adelaide', 'postal code': latitude '',' ':-34.0287, "longitude": 138.0986, ' metro_code ': '',' area_code' ":" "}

    The code I use is this and will display the string correctly for the first sample, but is empty in the second sample.

    RestServiceAdapter restServiceAdapter = Model.createRestServiceAdapter ();

    Claire each previously defined properties of the request, if any

    restServiceAdapter.clearRequestProperties ();


    Set the login name

    restServiceAdapter.setConnectionName ("GeoIPOAG");


    Specify the type of request

    restServiceAdapter.setRequestType (RestServiceAdapter.REQUEST_TYPE_GET);    MESSAGE switching makes no difference, get the same results

    Specify the number of attempts

    restServiceAdapter.setRetryLimit (0);

    ADDED to this to see that she had no effect - if not

    restServiceAdapter.addRequestProperty("Connection","Keep-Alive");

    restServiceAdapter.addRequestProperty ("Content-Type", "application/json");         Define what is recommended in the guide of dev MAF but has no effect

    restServiceAdapter.addRequestProperty ("Accept", "application/json");                Define what is recommended in the guide of dev MAF but has no effect

    Set the URI which is defined after the end point in the connections.xml.

    The application's endpoint + defined URI

    restServiceAdapter.setRequestURI("/json/122.109.131.63");

    Run the SEND and RECEIVE operation

    try {}

    System.out.println ("\nInvoking Service REST on GET and the details are" + restServiceAdapter.getRequestURI ());

    For a GET request, there is no payload

    String answer = (restServiceAdapter.send(""));

    System.out.println("\n**********************************************************************************************");

    System.out.println ("\nResponse GET album was" + response);

    System.out.println("\n**********************************************************************************************");

    } catch (Exception e) {}

    e.printStackTrace ();

    }

    Add this in case someone has this problem - the MAF for REST of treatment seems to require Content-Length. Without it, it will not process the answer - that is, the answer is «»

    It is a bit of a pain if you have a REST service on the API Oracle Gateway what not will BE NOT Content-Length of back (except if you call another server as part of your policy).

  • I can't open a backup file of favorites with json extension

    I opened the LIBRARY folder in TOOLS, and click BACKUP so that I can get a copy of my favorites to transfer to another laptop.

    I saved the file on the DESKTOP. It has an extension of json. Cannot open it. How can I open it. My registry is corrupt? Thank you, cp

    The use of a JSON backup is to restore the file through the bookmarks manager in a Firefox profile, which will replace all current bookmarks with those of this JSON backup.

    A JSON backup is a text file to the format of the object and is not very readable.

    If you want a readable backup then export the Favorites to an HTML file.

    Why do you want to open this file?

  • APEX5, get feet wet with json?

    Instead of Googling happy myriad of hits from json apex SF, I dare ask for advice on getting my feet wet with json and APEX5.

    1 where should json-related question - forums APEX5 or ADR or SQL

    2. What is the best handson tutorial to start?

    3 What kind - of json application tests that APEX5 instance is configured correctly to provide & consume json (can I say so?).

    4th another point to ponder?

    Rgrds Paavo

    PS. I know it's really read the fantastic manual, but I'm sure there are a lot of things to operate

    Hi paavo.

    Paavo wrote:

    Instead of Googling happy myriad of hits from json apex SF, I dare ask for advice on getting my feet wet with json and APEX5.

    1 where should json-related question - forums APEX5 or ADR or SQL

    If you have any question regarding:

    Oracle documentation:

    Blog links:

    and you can find many others.

    Kind regards

    Kiran

  • CS6 Error with JSON

    Updated one of my projects to CS6 and now get the error...

    Line 188 1061: call to a possibly undefined method decode a reference of static type Class.

    CODE:

    import com.adobe.serialization.json.JSON;

    Si ( » « ! is scormSuspendString) scormSuspend is JSON.decode (scormSuspendString);

    This also occurs with the JSON.encode.

    Due to differences in the CS6 and CS5.5, could this be another problem?

    Thank you

    instead of decode/encode, use parse/stringify.

    you are publishing for fp 11 + and use the native JSON class actionscript, not mike class room.

  • Need help with JSON.decode

    I get a query response JSON with about 4 deep layers of value of nested objects I need to pierce the. The JSON.decode examples that I find online are very simple and use it and the old syntax which is taken in charge in Flex 4.5.

    I was hoping that someone here could give me a tip or two to extract the values of 'html_instructions' of a JSON result like this:

    {
    "status": "OK."
    "routes": [{}
    'Summary': ' US-97 S and S I-5.
    "legs": [{}
    'steps': [{}
    "travel_mode": "En ROUTE."
    'start_location': {}
    "lat": 45.6692700,
    "lng" :-118.8421500
    },
    'end_location': {}
    "lat": 45.6697700,
    "lng" :-118.8456500
    },
    'polyline': {}
    "points": "{} wvuGljjtUJ'@DjBuBlP", "
    'levels': ' B? B ".
    },
    'Time': {}
    'value': 26,.
    "text": "1 min".
    },
    "html_instructions': ' head \u003cb\u003esouthwest\u003c/b\u003e on \u003cb\u003eMcKennon Rd\u003c / b\u003e to \u003cb\u003eSW Bartsch Rd/Co 1304 Rd\u003c/b\u003e."
    'distance': {}
    'value': 284.
    'text': '0.2 mi.
    }
    }, {
    "travel_mode": "En ROUTE."
    'start_location': {}
    "lat": 45.6697700,
    "lng" :-118.8456500
    },
    'end_location': {}
    "lat": 45.6700400,
    "lng" :-118.8466500
    },
    'polyline': {}
    'points': ' a {vuGh'ktUWrAIjASf @ ',} ".
    'levels': ' B? B ".
    },
    'Time': {}
    'value': 10,.
    "text": "1 min".
    },
    "html_instructions': ' go straight on \u003cb\u003eSW Bartsch Rd/Co 1304 Rd\u003c/b\u003e."
    'distance': {}
    'value': 85,.
    "text": "279 ft.
    }
    }

    }
    } ]
    }

    Thanks a lot, a lot in advance!

    Hello

    As I'm not sure of what api that you use to decode json: once convert you the object info you are looking for is available as:

    JSON.routes [0] .legs [0]. Steps [0] .html_instructions

    or:

    JSON.routes [N] .legs [N]. Steps [N] .html_instructions

    Where N is the length of the data "json" and the table is loaded data object, the more

    Kind regards

    Peter

  • 10.6.8 using.  With Safari I can view the Apple start page.  OK, using Firefox.

    10.6.8 using.  With Safari I can view the Apple start page.  OK, using Firefox.  What happens in the last 24 hours. How can I solve this?

    You can solve it using only not the OS X version 10.6, Apple Safari here on out!

    Over the years, there were no updating security for what be for OS X 10.6.8 Snow Leopard!

    This version of Safari is obsolete and has not been safe to use for many years.

    There is one more, last recommended Mozilla Firefox web browser update complete (worms) 48.0.0 that is always available, and probably will be more safe to use until the end of the year.

    https://www.Mozilla.org/en-us/Firefox/desktop/

    Mozilla is complete, at the end of the present in August, full support for Firefox on OS X 10.6 - 10, 8.

    OR

    Guaranteed ONLY (not more new web browser feature) support for an earlier version of th is permanent to Mozilla Firefox, web browser (worms. 45.0.0) through their program of Firefox ESR, (that you CAN download, install and use) which will continue to receive the support of a security update to Firefox until next April 2017 for OS X 10.6-10, 8.

    You can use these versions of the ESR. Ignore the notes support educational/business.

    https://www.Mozilla.org/en-us/Firefox/organizations/FAQ/

    OR

    See SeaMonkey.

    http://www.SeaMonkey-project.org/

    Good luck!

  • The AirPod are compatible only with iphone 7? Or we can use it with more than 6 s... or any android device?

    The AirPod are compatible only with iphone 7? Or we can use it with more than 6 s... or any android device?

    Here are the tech specs: http://www.apple.com/shop/product/MMEF2AM/A/airpods

    They are bluetooth devices, so they work with the iPhone 5 or more.

    See you soon,.

    GB

  • can I use Skype with the Ipad Pro or any other IPad?

    I want to know if I can use Skype with any kind of IPads?

    You can - the latest version of their app requires iOS 8 +: https://itunes.apple.com/us/app/skype-for-ipad/id442012681?mt=8

  • can I use FCP6 with el Capitan

    can I use FCP6 with el Capitan

    Application compatibility

    (2) application compatibility

    Information on the compatibility of 10.11 El Capitan

  • I know that this may be a lame question, but can I use Thunderbird with my Chrome browser and gmail account?

    I don't currently have firefox browser and very uncomfortable with Chrome for many years now. can I use Thunderbird with my Chrome browser? I want to manage a large mailing list for a nonprofit group that wants me to use Thunderbird.

    Thank you

    Reuben

    absolutely

  • How can I use tor with firefox?

    I found this Tor project recommends do not to use the customer of vidalia. Also, I found that the torbutton add-on has been removed and foxyproxy tor Wizard does not work.
    Is it possible to use tor with one other than its built-in firefox browser?

    I found that the Tor changed its default port 9050 to 9150 so you can create a proxy setting to help foxy proxy tor Wizard and change its port to 9150.
    You can also manually configure the Firefox proxy settings to use localhost on port 9150.

  • Using Sansung S3, not yet possible to share all the tabs opened (using NFC) with another phone NFC. But only the a main tab, I'm currently browsing is possible.

    Sansung S3 using, Android 4.1.2 Firefox 24.0; not yet possible to share all the tabs opened (using NFC) with another phone NFC. But only the a main tab, I'm currently browsing is possible to share. It is the function of current NFC function of Firefox?
    If so, when will it feature to share all the tabs?
    Thank you.

    I don't know if we implement this. Sharing of all the tabs you have open have many security and privacy issues. Someone forget that they had a tab open, they didn't want to share or miss-clicks on the sharing of all the option.

    We are looking for ways to better share tabs with devices that are located nearby. Especially if they are on the same WiFi network.

  • I use iCloud with office, laptop, phone

    I use iCloud with Apple Mackbook Air, desktop, iPhone and iPad Mini. I can't notes to synchronize on the laptop. On all other devices if I add a note on one, it appears on the other. Not so much on Macbook Air (10.10.5)?

    On the Macbook Air open System Preferences > iCloud.

    Clear the check box next to Notes here it again.

    Give iCloud minutes re sync your Notes.

  • Open with options: I want to add a new application to the list right click on file-> open with and rearrange the list so my search app is first. I know that I can use open with-> other and select any application, but it takes too much time since I u

    I want to add a new application to the list right click on file-> open with

    and also reorder the list so my search app is first / top of the list.

    I know that I can use open with-> other and select any application, but it takes too long I should use my intended application in this way several times a day.

    Basically, I'm looking for a configurable way configure open with, something more to send to Windows.

    Thank you very much for all the advice offered.

    The operating system, not you, not control that open with the menu command.

Maybe you are looking for

  • HP Envy Phoenix 810-460: HP Envy Phoenix 810-460 K5G86AA MSI Kaili2 MS - 7826 V2 Intel Socket 1150 Broadwell upgrade

    My father bought this computer in August of last year just before that the 1150 of Socket Intel chips Broadwell (5775 i7 and i5 5675 C).  This HP computer contains a Z97 chipset which should have support for both of these chips with a BIOS update.  H

  • The combination of columns or cells

    In a GIANT spreadsheet I I'd like to combine the columns. Column A is a list of part numbers, column C is a list of product names, column D is a list of product sizes: I want to make a version of this spreadsheet in which these lists are combined: I

  • Take 100% of CPU Utilization in windows Xp sp3.

    Hello In the 'System' service task manager was taking 100 CPU usage, can someone help out of this... Detail of PC,Microsoft Windows XP sp3.512 MB memory.P4 CPU. I'll make this process...CHKDSK.ALL THE ANALYSIS WITH MICROSOFT SECURITY ESSENTIAL. resto

  • I can not install iis on my system

    After I have reinstall vista premium on my laptop 2 days ago, this does not install/turn on iis on my system with windows features turn on and outside. before I reinstall vista is was turn on my system. What can be the reason and what can do to solve

  • How to share the root of a hard disk in Win7?

    I am able to share a folder, but cannot share the root of a hard disk. Homegroup is off.  In addition, even if I have the password to 'OFF' I always get invited to do since the XP computers on the network, but not Vista computers. Weird? Win7 compute