Parsing Json data to Array

i have json string which i want to parse in string and add in Array,
also i want to access this value as per field name to display in TextBox.
i have parse the json data in string format but i want to add it in array as per their field name,so that i can access it in textfields.
[{"userid":1,"uname":"andruw","address":"west","city":"london","email":"[email protected]"},
{"userid":2,"uname":"pamela","address":"east","city":"london","email":"[email protected]"},
{"userid":3,"uname":"penny","address":"south","city":"paris","email":"[email protected]"},
{"userid":4,"uname":"jhon","address":"north","city":"zurich","email":"[email protected]"}]

Why do you wnat it string in hte first place, now you need to split it to get the info. The honest thing to do is to create a custom class to hold this info and populate the array with objects created from JSON. That way you can easily map data to UI controls.
class Person
    userId:int;
    uname:String;
    address:String;
    city:String;
    email:String;
My 2 cents,
C

Similar Messages

  • C# Parsing JSON data within Mobile project OR via Controller Issue

    When I invoke the following to a custom controller to return data to my client (Windows Phone 8.1 app):
    var _lines = await App.MobileService.InvokeApiAsync<List<Tfl.Api.Presentation.Entities.Line>>("lines", System.Net.Http.HttpMethod.Get, new Dictionary<string, string>
    {"url", "http://api.tfl.gov.uk/Line"}
    I received the following Exception:-
    FileNotFoundException was caught
    Could not load file or assembly 'System.Runtime.Serialization,
    Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one
    of its dependencies. The system cannot find the file specified.
    However, I successfully parse the JSON data via the controller [I did have an image here displaying the data, but not enough rep to post!] and I also have no references to the above dll in my Windows Phone application.
    Any ideas?
    Note: Occurs using either local parsing within the mobile app or via controllers in a service app; also running VS Ultimate 2013 with Update 4

    Hi James,
    The data is deserializing using System.Runtime.Serialization 4.0.0.0 on the client side (which is targeting .NET 4.5). I am using a third party DLL found here (api.tfl.gov.uk) which contains all of the data transfer objects required to map the data from
    the JSON into an object structure.
    I have tested this DLL also within a console application and runs as expected, deserializing and mapping data etc; could the issue be that the DLL I'm using containing DataContract and DataMember annotations cannot be used as a reference within the Windows
    Phone 8.1 app?
    I say this because I have a solution whereby I 'copy' the DTO modes in the DLL into plain models using the same code (minus Serialization annotations) and the JSON then is able to deserialize and map to those in the phone.
    So the solution are present is to create my own models, however if you've any other ideas/workarounds that would be great to know in the future where I can just reference the third party DLL.
    Thanks for the response!
    --David

  • JSON.parse: unexpected non-whitespace character after JSON data

    I am having problem using cold fusion and jquery.ajax it will throw error
    JSON.parse: unexpected non-whitespace character after JSON data
    this is the response in firebug {"EMPCODE":"E-00001"}
    child.cfm
      <cfif IsDefined("empmycode")>
             <cfset  myarray= getempCode(#mycode#)>
             <cfoutput>#myarray#</cfoutput>
      </cfif>
    <cffunction name="getempCode">
           <cfargument name="empcode">
             <cfquery  name="empQuery" datasource="#datasource#">
                   Select empcode from employee where empcode = '#empcode#'
             </cfquery>
                <cfset mystruct = StructNew()>  
                <cfset mystruct.empcode=#empQuery.empcode#>
            <cfreturn   SerializeJSON(mystruct)>
      </cffunction>
    parent.cfm
    $.ajax({
        type: 'post',
            data: {empmycode:empcode}, 
        url: 'child.cfm',
        success:function(data){
        var myobjc = jQuery.parseJSON(data);
        console.log(myobj.empcode);
    Thank you in advance

    jemz wrote:
      <cfif IsDefined("empmycode")>
             <cfset  myarray= getempCode(#mycode#)>
             <cfoutput>#myarray#</cfoutput>
      </cfif>
      <cffunction name="getempCode">
           <cfargument name="empcode">
             <cfquery  name="empQuery" datasource="#datasource#">
                   Select empcode from employee where empcode = '#empcode#'
             </cfquery>
                <cfset mystruct = StructNew()>  
                <cfset mystruct.empcode=#empQuery.empcode#>
            <cfreturn   SerializeJSON(mystruct)>
      </cffunction>
    The above code is confusing. You test for the existence of empmycode, yet you actually use mycode instead. In addition, what you call an array isn't, and you fail to 'var' the method's local variables.
    You could modify the code, by scoping, as well as bearing in mind what Carl has said:
    <cfif IsDefined("form.empmycode")>
        <cfset  code= getempCode(form.empmycode)>
        <cfoutput>#code#</cfoutput>
    </cfif>
    <cffunction name="getempCode">
    <cfargument name="empcode">
    <cfset var mystruct = StructNew()>
    <!--- Alternative:  <cfqueryparam cfsqltype="cf_sql_varchar" value="'#arguments.empcode#"> --->
             <cfquery  name="empQuery" datasource="#datasource#">
                   Select empcode from employee where empcode = <cfqueryparam cfsqltype="cf_sql_integer" value="'#arguments.empcode#">
             </cfquery>
    <cfset mystruct.empcode=empQuery.empcode>
    <cfreturn   SerializeJSON(mystruct)>
    </cffunction>

  • How do you store parsed XML data in an array

    Hi, i am trying to complete a small program which implements the SAX parser to parse an XML file. My problem is that i am writing a custom class to store the parsed data into an array, and then make the array available to the main program via a simple method which returns the array. I know this must be very simple to do, but i seem to have developed a mental block with this part of the program. I can parse the data and print all the elements to the screen, but i just cant figure out how to store all the data elements into the array. I will post the class which is supposed to do this, and ask anyone out there if they know what i'm doing wrong, and also, if there is a more effeicient way of achieving this ( i expect there definitely is!! but i have never used the SAX parser before and am getting confused by the API docs on it!!) Any help very much appreciated.
    Here is my attempt at coding the class to handle the parsed XML data
    class Sink extends org.xml.sax.helpers.DefaultHandler
         implements org.xml.sax.ContentHandler{
    Customer[] customers = new Customer[20];
         int count = 1;
         int x = 0;
         int tagCount = 0;
         String name;
    String custID;
         String username;
         String address;
         String phoneNum;
    public void startElement(String uri, String localName, String rawName, final org.xml.sax.Attributes attributes)throws org.xml.sax.SAXException{
    //count the number of <name> tags in the XML file
         if(rawName.equals("name")){
              tagCount++;
    public void characters(char[] ch, int start, int len){
    //get the current string
         String text = new String(ch, start, len);
         String text1 = text.trim();
    //there are 5 elements for each customer found in the XML file so when the count reaches 6
    // i reset this to 1
         if(count == 6){
         count = count - 5;
         if(text1.length()>0 && count == 1){
              name = text1;
              System.out.println(name);
              }else{
         if(text1.length()>0 && count == 2){
              custID = text1;
              System.out.println(custID);
                   }else{
                   if(text1.length()>0 && count == 3){
                   username = text1;
                   System.out.println(username);
                   }else{
                        if(text1.length()>0 && count == 4){
                        address = text1;
                        System.out.println(address);
                        }else{
                        if(text1.length()>0 && count == 5){
                             phoneNum = text1;
                             System.out.println(phoneNum);
                             //add data to the customer array
                             customers[x] = new Customer(name, custID, username, address, phoneNum);
    // increment the array index counter
                        x = x+1;
                        }//end of if
                        }//end else
                        }//end else
                   }//end else
              }//end else
    }//end of characters method
    public void endDocument(){
         System.out.println("There are " + tagCount +
         " <name> elements.");
    }//end of class Sink
    Before the end of this class i also need to make the array available to the calling program!!
    Any help would be much appreciated
    Thanks
    Iain

    Ok, yer going about this all the wrong way. You shouldn't have to maintain a count of all the elements. Basically you are locking yourself into the XML tags not only all being there but are assuming they are all in the same order. What you should do is in your characters() method, put all of the characters into a string buffer. Then, in endElement() (which you dont use btw, you should) you grab the information that is in the string buffer and store it into your Customer object depending on what the tagName is.
    Also, you should probably use a List to store all the Customer objects and not an single array, it's more dynamic and you arent locked into a set number of Customers.
    I wont do it all for you, but I'll give you a good outline to use.
    public class CustomerHandler extends DefaultHandler {
        private java.util.List customerList;  // List of Customer objects
        private java.util.StringBuffer buf;   // StringBuffer to store the string of characters between the start and end tags
        private Customer customer;  // Customer object that is initialized with each entry.
        public CustomerHandler() {
            customerList = new java.util.ArrayList();   // Initialize the List
            buf = new java.util.StringBuffer();   // Initialize the string buffer
        //  Make your customer list available to other classes
        public java.util.List getCustomerList() {
            return customerList;
        public void startElement(String nsURI, String sName, String tagName, Attributes attributes) throws SAXException {
            // Clear the String Buffer
            //  If the tagName is "Customer" then create a new Customer object
        public void characters(char[] ch, int start, int length) {
            //  append the characters into the string buffer
        public void endElement(String nsURI, String sName, String tagName) throws SAXException {
            // If the tagName is "Customer" add your customer object to the List
            // Place the data from the String Buffer into a String
            //  Depending on the tagName, call the appropriate set method on your customer object
    }

  • How to parse URL Data into an NSString Array in iphone application

    Hi Every one
    I am newbie to iphone programming. I am having problem with reading and displaying the data into the table view. My application has to be designed like this. There is a csv file in the server machine and I have to access that URL line by line. Each line consists of 8 comma separated values. Consider each line has first name, second name and so on. I have to parse the data with comma and a newline and store them in an array of first name, second name array an so on. The next thing is I have to set first name second name combined and must be displayed in the UITableView. Can anyone provide me with an example of how to do it? I know I am asking the solution but I encountered a problem in connection methods separately and parsing simultaneously. You help is much appreciated.
    Thanks

    What does that have to do with a URL?
    The only thing that doesn't sound good is "array of first name" and "second name array". For each row, extract all the field and store them in an NSDictionary. Add a derived field consisting of first name concatenated with last name. That will be easy to display in a table.

  • Parse/seperate data from string

    I have a string that is returned from Google GeoCoding:
    {   "name": "193 Farrow Hill Road,Davisville,WV",   "Status": {     "code": 200,     "request": "geocode"   },   "Placemark": [ {     "id": "p1",     "address": "Davisville, WV, USA",     "AddressDetails": {    "Accuracy" : 4,    "Country" : {       "AdministrativeArea" : {          "AdministrativeAreaName" : "WV",          "SubAdministrativeArea" : {             "Locality" : {                "LocalityName" : "Davisville"             },             "SubAdministrativeAreaName" : "Wood"          }       },       "CountryName" : "USA",       "CountryNameCode" : "US"    } },     "ExtendedData": {       "LatLonBox": {         "north": 39.2357655,         "south": 39.1665921,         "east": -81.4344257,         "west": -81.5624851       }     },     "Point": {       "coordinates": [ -81.4984554, 39.2011873, 0 ]     }   } ] }
    I want to be able to parse this data into variables that I can use and update a table.
    I currently use ListGetAt() function and try to find common delimiters to narrow down what I am trying to parse, but this processes does not always return the results I am needing.
    Does anyone know of any faster more robust way of parsing this string down to variables? And, it could be that I am not using the ListGetAt() to its full potential as well....
    What I need most out of this string is in bold below...you'll notice different string lengths depending on if it recognizes the street address or not.
    This is the string returned if it DOES NOT recognize the street address:
    {   "name": "193 Farrow Hill Road,Davisville,WV",   "Status": {     "code": 200,     "request": "geocode"   },   "Placemark": [ {     "id": "p1",     "address": "Davisville, WV, USA",     "AddressDetails": {    "Accuracy" : 4,    "Country" : {       "AdministrativeArea" : {          "AdministrativeAreaName" : "WV",          "SubAdministrativeArea" : {             "Locality" : {                "LocalityName" : "Davisville"             },             "SubAdministrativeAreaName" : "Wood"          }       },       "CountryName" : "USA",       "CountryNameCode" : "US"    } },     "ExtendedData": {       "LatLonBox": {         "north": 39.2357655,         "south": 39.1665921,         "east": -81.4344257,         "west": -81.5624851       }     },     "Point": {       "coordinates": [ -81.4984554, 39.2011873, 0 ]     }   } ] }
    This is the string returned if it DOES recognize the street address:
    {   "name": "W7499 So. Mound Rd,Neillsville,WI",   "Status": {     "code": 200,     "request": "geocode"   },   "Placemark": [ {     "id": "p1",     "address": "S Mound Rd, Neillsville, WI 54456, USA",     "AddressDetails": {    "Accuracy" : 6,    "Country" : {       "AdministrativeArea" : {          "AdministrativeAreaName" : "WI",          "SubAdministrativeArea" : {             "Locality" : {                "LocalityName" : "Neillsville",                "PostalCode" : {                   "PostalCodeNumber" : "54456"                },                "Thoroughfare" : {                   "ThoroughfareName" : "S Mound Rd"                }             },             "SubAdministrativeAreaName" : "Clark"          }       },       "CountryName" : "USA",       "CountryNameCode" : "US"    } },     "ExtendedData": {       "LatLonBox": {         "north": 44.5921279,         "south": 44.5858326,         "east": -90.5981846,         "west": -90.6802503       }     },     "Point": {       "coordinates": [ -90.6394276, 44.5889072, 0 ]     }   }, {     "id": "p2",     "address": "S Mound Rd, Neillsville, WI 54456, USA",     "AddressDetails": {    "Accuracy" : 6,    "Country" : {       "AdministrativeArea" : {          "AdministrativeAreaName" : "WI",          "SubAdministrativeArea" : {             "Locality" : {                "LocalityName" : "Neillsville",                "PostalCode" : {                   "PostalCodeNumber" : "54456"                },                "Thoroughfare" : {                   "ThoroughfareName" : "S Mound Rd"                }             },             "SubAdministrativeAreaName" : "Clark"          }       },       "CountryName" : "USA",       "CountryNameCode" : "US"    } },     "ExtendedData": {       "LatLonBox": {         "north": 44.5920678,         "south": 44.5857725,         "east": -90.6802503,         "west": -90.7004168       }     },     "Point": {       "coordinates": [ -90.6899796, 44.5889209, 0 ]     }   } ] }

    That is indeed JSON, as Jochem says. You can pick out data using structs and arrays. You will know which structure or array functionality to use after doing something like this
    <cfsavecontent variable="myJSON1">
    {   "name": "193 Farrow Hill Road,Davisville,WV",   "Status": {     "code": 200,     "request": "geocode"   },   "Placemark": [ {     "id": "p1",     "address": "Davisville, WV, USA",     "AddressDetails": {    "Accuracy" : 4,    "Country" : {       "AdministrativeArea" : {          "AdministrativeAreaName" : "WV",          "SubAdministrativeArea" : {             "Locality" : {                "LocalityName" : "Davisville"             },             "SubAdministrativeAreaName" : "Wood"          }       },       "CountryName" : "USA",       "CountryNameCode" : "US"    } },     "ExtendedData": {       "LatLonBox": {         "north": 39.2357655,         "south": 39.1665921,         "east": -81.4344257,         "west": -81.5624851       }     },     "Point": {       "coordinates": [ -81.4984554, 39.2011873, 0 ]     }   } ] }
    </cfsavecontent>
    <cfsavecontent variable="myJSON2">
    {   "name": "W7499 So. Mound Rd,Neillsville,WI",   "Status": {     "code": 200,     "request": "geocode"   },   "Placemark": [ {     "id": "p1",     "address": "S Mound Rd, Neillsville, WI 54456, USA",     "AddressDetails": {    "Accuracy" : 6,    "Country" : {       "AdministrativeArea" : {          "AdministrativeAreaName" : "WI",          "SubAdministrativeArea" : {             "Locality" : {                "LocalityName" : "Neillsville",                "PostalCode" : {                   "PostalCodeNumber" : "54456"                },                "Thoroughfare" : {                   "ThoroughfareName" : "S Mound Rd"                }             },             "SubAdministrativeAreaName" : "Clark"          }       },       "CountryName" : "USA",       "CountryNameCode" : "US"    } },     "ExtendedData": {       "LatLonBox": {         "north": 44.5921279,         "south": 44.5858326,         "east": -90.5981846,         "west": -90.6802503       }     },     "Point": {       "coordinates": [ -90.6394276, 44.5889072, 0 ]     }   }, {     "id": "p2",     "address": "S Mound Rd, Neillsville, WI 54456, USA",     "AddressDetails": {    "Accuracy" : 6,    "Country" : {       "AdministrativeArea" : {          "AdministrativeAreaName" : "WI",          "SubAdministrativeArea" : {             "Locality" : {                "LocalityName" : "Neillsville",                "PostalCode" : {                   "PostalCodeNumber" : "54456"                },                "Thoroughfare" : {                   "ThoroughfareName" : "S Mound Rd"                }             },             "SubAdministrativeAreaName" : "Clark"          }       },       "CountryName" : "USA",       "CountryNameCode" : "US"    } },     "ExtendedData": {       "LatLonBox": {         "north": 44.5920678,         "south": 44.5857725,         "east": -90.6802503,         "west": -90.7004168       }     },     "Point": {       "coordinates": [ -90.6899796, 44.5889209, 0 ]     }   } ] }
    </cfsavecontent>
    <cfdump var="#deserializeJSON(myJSON1)#">
    <cfdump var="#deserializeJSON(myJSON2)#">

  • Populating JSON Data to Combobox - Need Help!

    Hello,
    I am trying to use a dynamicly created JSON comming from a webservice to populate comboboxes. I am really new to Flex and ActionScript 3.0.
    The problem what i have here is that my combobox stays empty. I am trying to fill it with all values from "key" (representing the manufacturers)
    Here´s my Code so far:
    [CODE]<?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute"
                    creationComplete="service.send(params)" xmlns:s="library://ns.adobe.com/flex/spark">
        <mx:Script>
            <![CDATA[
                import com.adobe.serialization.json.JSON;
                import mx.collections.ArrayCollection;
                import mx.rpc.events.ResultEvent;
                public var myURL:String = "http://dev.ws.topdata.de/data/tdifdata.php?";
                public var params:Object = {Lookup: "DeviceManufacturerId"};
                private function onJSONLoad(event:ResultEvent):void
                    //get the raw JSON data and cast to String
                    var rawData:String = String(event.result);
                    //decode the data to ActionScript using the JSON API
                    //in this case, the JSON data is a serialize Array of Objects.
                    var arr:Array = (JSON.decode(rawData) as Array);
                    //create a new ArrayCollection passing the de-serialized Array
                    //ArrayCollections work better as DataProviders, as they can
                    //be watched for changes.
                    var dp:ArrayCollection = new ArrayCollection(arr);
                    //pass the ArrayCollection to the Combobox as its dataProvider.
                    dropdown.dataProvider = dp;
                    trace(rawData);
            ]]>
        </mx:Script>
        <mx:HTTPService id="service" method="GET" resultFormat="text" url="{myURL}" result="onJSONLoad(event)">
        </mx:HTTPService>
        <s:ComboBox x="26" y="33" labelField="key" id="dropdown"/>   
    </mx:Application>[/CODE]
    trace(rawData); returns something like
    [CODE]"1607":
                "key": "Xitan",
                "value": "2283",
                "isPremium": "0"
        "1608":
                "key": "Xitron",
                "value": "2284",
                "isPremium": "0"
        "1609": [/CODE]
    Now i´ve tried to bind this dataProvider for my first combobox listing all items with the value from "key" but my combobox stays blank/empty....

    I tried the following now and it says "can´t convert obect@... to Array"  maybe there is something wrong with the JSON outout from the  webservice? But the JSON from the webservice validates, however if i test it with a small own JSON file locally it works...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="absolute"
                    minWidth="955" minHeight="600"
                    applicationComplete="init()"
                    frameRate="30">
        <mx:Script>
            <![CDATA[
                import com.adobe.serialization.json.JSON;
                // var ini
                private var filePath:String = "http://dev.ws.topdata.de/data/tdifdata.php?Lookup=DeviceManufacturerId";
                private var urlLoader:URLLoader;
                private var jsonDataArray:Array;
                private function init():void
                    // Add event listener for button click
                    btn.addEventListener(MouseEvent.CLICK,loadJSONFile);
                private function loadJSONFile(e:MouseEvent=null):void
                    // Load file
                    urlLoader = new URLLoader();
                    urlLoader.addEventListener(Event.COMPLETE, fileLoaded,false,0,true);
                    //urlLoader.addEventListener(IOErrorEvent.IO_ERROR, fileLoadFailed);
                    urlLoader.load(new URLRequest(filePath));
                private function fileLoaded(e:Event):void
                    // Clean up file load event listeners
                    urlLoader.removeEventListener(Event.COMPLETE, fileLoaded);
                    // If you wanted to get the data from the event use the line below
                    //var urlLoader:URLLoader = URLLoader(event.target);
                    // Parse the file to an array
                    jsonDataArray = JSON.decode(urlLoader.data);
                    trace(jsonDataArray);
                    // Proceed to do something with the loaded data
                    proceed();
                private function proceed():void
                    // Retrieve data tests
                    trace("jsonDataArray[0].name = " + jsonDataArray[0].name);
                    // Populate data grid with our JSON Data
                    dg.dataProvider = jsonDataArray;               
            ]]>
        </mx:Script>
        <mx:DataGrid horizontalCenter="0" top="100" id="dg" width="400" height="200">
            <mx:columns>
                <mx:DataGridColumn headerText="Key" dataField="key"/>
                <mx:DataGridColumn headerText="Value" dataField="value"/>
            </mx:columns>
        </mx:DataGrid>
        <mx:Label text="An example of parsing JSON using AS3Corelib" color="#FFFFFF" fontWeight="bold" left="10" top="10" fontSize="14"/>
        <mx:Button label="PARSE DATA INTO DATA GRID" horizontalCenter="0" top="70" width="400" id="btn"/>
    </mx:Application>

  • Script for parsing xml data and inserting in DB

    Thank you for reading.
    I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
    I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
    Method 1
    Create or replace procedure parse_xml is 
      l_bfile   BFILE; 
      l_clob    CLOB; 
      l_parser  dbms_xmlparser.Parser; 
      l_doc     dbms_xmldom.DOMDocument; 
      l_nl      dbms_xmldom.DOMNodeList; 
      l_n       dbms_xmldom.DOMNode; 
      l_file      dbms_xmldom.DOMNodeList; 
      l_filen       dbms_xmldom.DOMNode; 
      lv_value VARCHAR2(1000); 
       l_ch      dbms_xmldom.DOMNode; 
    l_partname varchar2(100); 
    l_filename varchar2(1000); 
      l_temp    VARCHAR2(1000); 
      TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE; 
      t_tab  tab_type := tab_type(); 
    BEGIN 
      l_bfile := BFileName('DIR1', 'SoftwareParts.xml'); 
      dbms_lob.createtemporary(l_clob, cache=>FALSE); 
      dbms_lob.open(l_bfile, dbms_lob.lob_readonly); 
      dbms_lob.loadFromFile(dest_lob => l_clob,    src_lob  => l_bfile,    amount   => dbms_lob.getLength(l_bfile)); 
      dbms_lob.close(l_bfile);  
      dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY'''); 
      l_parser := dbms_xmlparser.newParser; 
      dbms_xmlparser.parseClob(l_parser, l_clob); 
      l_doc := dbms_xmlparser.getDocument(l_parser); 
        dbms_lob.freetemporary(l_clob); 
      dbms_xmlparser.freeParser(l_parser); 
      l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part'); 
        FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP 
        l_n := dbms_xmldom.item(l_nl, cur_emp); 
        t_tab.extend; 
        dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname); 
        t_tab(t_tab.last).partname := l_partname; 
        l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName'); 
        FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP 
          l_ch := dbms_xmldom.item(l_file, cur_ch); 
          lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch)); 
          if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if; 
          t_tab(t_tab.last).filename := lv_value; 
        t_tab.extend; 
       END LOOP; 
       END LOOP; 
        t_tab.delete(t_tab.last); 
      FOR cur_emp IN t_tab.first .. t_tab.last LOOP 
      if t_tab(cur_emp).partname is not null and  t_tab(cur_emp).filename is not null then 
        INSERT INTO tab_software_parts 
        VALUES 
        (t_tab(cur_emp).partname, t_tab(cur_emp).filename); 
        end if; 
      END LOOP; 
      COMMIT; 
      dbms_xmldom.freeDocument(l_doc); 
    EXCEPTION 
      WHEN OTHERS THEN 
        dbms_lob.freetemporary(l_clob); 
        dbms_xmlparser.freeParser(l_parser); 
        dbms_xmldom.freeDocument(l_doc); 
    END; 
    <TWObject className="TWObject">
      <array size="240">
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[30]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[GB]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
        <item>
          <variable type="QuestionDetail">
            <questionId type="String"><![CDATA[40]]></questionId>
            <questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
            <country type="String"><![CDATA[DE]]></country>
            <questionText type="String"><![CDATA[Please indicate]]></questionText>
            <optionType type="String"><![CDATA[RadioButton]]></optionType>
            <answerOptions type="String[]">
              <item><![CDATA[Yes]]></item>
              <item><![CDATA[No]]></item>
            </answerOptions>
            <ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
            <parentQuestionId type="String"></parentQuestionId>
            <parentQuestionResp type="String"></parentQuestionResp>
          </variable>
        </item>
      </array>
    </TWObject>

    Reposted as
    Script to parse XML data into Oracle DB

  • DeserializeJSON - is there a limit on the size of the JSON data that can be converted?

    I have some valid JSON data that's being converted successfully by DeserializeJSON... until it gets to a certain size, or that's certainly what appears to be happening.  The breaking point seems to be somewhere in the neighborhood of 35,000 characters... about 35KB.  When the conversion fails, it fails with a "JSON parsing failure: Unexpected end of JSON string" message.  And when the conversion fails, the JSON data is deemed to be valid per tools like this one:  http://www.freeformatter.com/json-validator.html.
    So, is there a limit on the size of the JSON data that can be converted by DeserializeJSON?
    Thanks!

    Thanks Carl.
    The JSON is being submitted in its entirety, confirmed by Fiddler.  And it's actually being successfully saved to a SQL Server nvarchar(MAX) field too.  I can validate that saved JSON.
    I'm actually grabbing the JSON to convert directly from the SQL Server, and your comments / thoughts led me down the path of resolution.
    Turns out that the JSON was being truncated prior to getting to the DeserializeJSON command, but it was the cfquery pull that was doing the truncating.  The fix was to enable "long text retrieval (CLOB)" for this datasource in CF Admin.  I'd never run into that before or even knew that this setting existed.
    Thanks again for your comments!

  • Parse JSON records using PL/SQL and store the output in Oracle Database.

    We have JSON data/record stored in a Oracle table as CLOB(database version 10g). We need to read/parse this JSON data and recognize the relevant tags and corresponding values in this JSON data and then insert these id/values into a separate Oracle staging table.
    Please let me know if there is any re-usable code available for this.
    We are looking for solution that does this manipulation in pl/sql. If this is not feasible, even Java code approach is fine.
    Regards,
    Kiranmayi.

    Hello,
    PL/JSON | Free software downloads at SourceForge.net
    ERASME - pl/sql library for JSON
    Regards
    Marcus

  • Modify JSON data after Approval

    I've managed to write my own UI5 app based on the "Building SAP Fiori-like UIs with SAPUI5", and I want the Approve function to work now.
    I have the following JSON data detail:
      "BusinessPartnerList": [
      "BPId": "0100000000",
      "Role": "01",
      "EmailAddress": "[email protected]",
      "PhoneNumber": "6789",
      "WebAddress": "http://www.sap.com",
      "CompanyName": "SAP",
      "LegalForm": "AG",
      "Country": "DE",
      "City": "Walldorf",
      "PostalCode": "69190",
      "Street": "Dietmar-Hopp-Allee",
      "Building": "15",
      "SalesOrders" : [
      "SalesOrderID": "0500000009",
      "Netto Amount": "3338.00",
      "Time Stamp": "2014.04.28. 9:00:00",
      "Gross Amount": "3972.22",
      "Status": "N",
      "CurrencyCode": "EUR",
      "Items": [
      "Position": "0000000010",
      "QuantityUnit" : "EA",
      "Tax": "181.64",
      "ProductName": "First Item Name",
      "ProductID": "HT-1000",
      "Quantity": "1",
      "DeliveryDate": "2014-05-05T07:00:00.0000000",
      "CurrencyCode": "EUR"
      "Position": "0000000020",
      "QuantityUnit" : "EA",
      "Tax": "596.60",
      "ProductName": "Second Item Name",
      "ProductID": "HT-1002",
      "Quantity": "2",
      "DeliveryDate": "2014-05-05T07:00:00.0000000",
      "CurrencyCode": "USD"
      "SalesOrderID": "0500000030",
      "Netto Amount": "22337.00",
      "Time Stamp": "2014.04.28. 9:00:00",
      "Gross Amount": "26581.03",
      "Status": "P",
      "CurrencyCode": "EUR"
      "SalesOrderID": "0500000039",
      "Netto Amount": "3338.00",
      "Time Stamp": "2014.04.28. 9:00:00",
      "Gross Amount": "3972.22",
      "CurrencyCode": "EUR",
      "Status": "N"
    I can list the SalesOrders for the specific partner, and than list the items of the specific SalesOrder.
    Now I'd like to Approve the order, and change it's status from "n" to "P" in the JSON file as well.
    But I have no idea how to do it in the SalesOrderItem.controller.
    I hope someone can help me

    Since "BusinessPartnerList" and "SalesOrders"  are both arrays, i think you need some index in your path.
    if you want to adress a specific business partner and sales order, you would need something like oJsonModel.setProperty("/BussinessPartnerList/0/SalesOrders/1/Status" , 'P' );

  • Create report based on JSON data

    Dear All,
    I'm on Oracle APEX 4.1 and Oracle 11g. I'm receiving JSON data in my application and would like to print report based on JSON data without storing it in any table.
    Can you please suggest best way to achieve it?
    Regards,
    Chintan

    Hi,
    in 4.1 you can for example use the open source PL/JSON library (http://sourceforge.net/projects/pljson/) to parse JSON.
    In APEX 5.0, we currently plan to add a JSON API package that e.g. can be used to convert JSON to XML. Here is an example:
    SQL> select col1, col2
      2  from xmltable (
      3      '/json/row'
      4      passing apex_json.parse('[{"col1": 1, "col2": "hello"},{"col1": 2, "col2": "world"}]')
      5      columns
      6          col1 number path '/row/col1',
      7          col2 varchar2(5) path '/row/col2' );
                    COL1 COL2
                       1 hello
                       2 world
    At the last OOW, it was also announced that the RDBMS will provide native support. That should be the preferred option in the future.
    Regards,
    Christian

  • What's the best way to read JSON data?

    Hi all;
    What is the best way to read in JSON data? And is the best way to use it once read in to turn it into XML and apply XPath?
    thanks - dave

    jtahlborn wrote:
    without having a better understanding of what your definition of "use it" is, this question is essentially unanswerable. Jackson is a fairly popular library for translating json to/from java objects. the json website provides a very basic library for parsing to/from xml. which one is the "best" depends on what you want to do with it.Good point. We have a reporting product ([www.windward.net|http://www.windward.net]) and we've had a number of people ask us for JSON support. But how complex the data is and what they want to pull is all over the place. The one thing that's commin is they generally want to pull down the JSON data, and then put specific items from that in the report.
    XML/XPath struck me as a good way to do this for a couple of reasons. First it seems to map well to the JSON data layout. Second it provides a known query language. Third, we have a really good XPath wizard and we could then use it for JSON also.
    ??? - thanks - dave

  • Invoking a method using reflection with json data as argument

    Hi,
    I want to invoke a method using reflection and this method have one argument . Now I want to pass a json data as an argument to this method .Please see the following code.
    int HelloWorld(int Id){
    return Id;
    json data{"Id":43}
    how can I use the reflection to use the json.
    Please provide your guidelines

    Thanks for your reply, I am building a windows console application .And I want to convert the json data to object array to use in Method Base.Invoke method.
    Regards,
    Ethan
    Maybe you could select the correct language development forum here:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=vslanguages&filter=alltypes&sort=lastpostdesc
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Too big switch - get data from array

    I have text file (CSV). Parse file and set data to array, e.g. ArrayList. Get data from array and initialize object MyDoc (by setXXX methods)
         for (int index = 0; index < list.size(); index++) {
                   currentElement = list.get(index);
                   switch (index) {
                   case 0:
                        myDoc.setField1(currentElement);
                        break;
                   case 1:
                        myDoc.setField2(currentElement);
                        break;
                   case 70:
                        myDoc.setField70(currentElement);
                        break;OK. But problem is that object MyDoc have many fields (70 fields). And "switch" become to big. (70 setXXX methods). Can I set fields to object MyDoc without "switch"?

    johndjr wrote:
    Just don't use a switch. It is not really helping any in this case.
    you can just do all the calls explicitly.
    Like so
    myDoc.setField1(list.get(0));
    myDoc.setField2(list.get(1));
    myDoc.setField70(list.get(69));I might convert the list to an array first simply because it seems more natural to me.
    I'm not too sure if it really matters all that much if list is an ArrayList.
    String[] values = list.toArray();
    myDoc.setField1(values[0]);
    myDoc.setField2(values[1]);
    myDoc.setField70(values[69]);you should check that toArray() call, I might not have the correct method I'm kind of doing this off the cuff.I think it is second thoughts day.
    I don't like the hard coded numbers. what I wrote should have defined constants for those values.
    static final int FLD1 = 0;
    static final int FLD70 = 69;
    String[] values = list.toArray();
    myDoc.setField1(values[FLD1]);
    myDoc.setField2(values[FLD2]);
    myDoc.setField70(values[FLD70]);
    Edited by: johndjr on Apr 17, 2009 1:33 PM
    forgot the constants

Maybe you are looking for

  • Why does pressing the down arrow button result in going to the bottom of the page and being nunable to go up or down one line at a time?

    i dont know what to say in way of clarification. when looking at a page i am forced to use the "slide" on the margin which is very sensitive on very long documents instead of the down arrow to move one line. pressing the arrow results in going to the

  • Support for Lumia 720,820,520,620

    Hi, I do understand that lumia 720 is year old device. But you haven't yet run any promotional offers for the device. Like in case of 525,1020, 1520 and 625 etc you had Gameloft games or Vouchers for buying apps. However this isn't in the case for 62

  • Changing images on JButtons

    hi all, I have a collection of icons that having images available in multiple sizes. The program my company is working on is geared towards deaf/hard of hearing and sight impaired individuals. I have assigned all the buttons images - however I want t

  • Epson RX620, OS 9.2 - Chooser problem

    Using Mac OS9.2 USB does not show on the right half of the chooser when I select Epson Photo Sytuls RX620. When I try to print, I get "The Stylus Photo Rx620 printer drive is not correctly selected. Please use chooser to select Stylus Photo Rx620." I

  • What keyboards are good for logic?

    I'm pretty new to logic and first of all it is incredibly confusing. I find that it's kind of hard to lay out notes just using my mouse or track pad, so are there anying musical USB keyboards available that are compatible with Logic?