Looping through json object in a query string

Hi
I have a json object in my query string and would like to loop through it, do i convert it to an array, or a map, so that i can loop through it?
I get the object from the url which looks like this:
{"CREATEDBYNAME":"TEST_ADMIN","FIRSTNAME":"John","TYPEID":"1900000000"}
I would then like to loop through it so that i can make a string that would look like:
"CREATEDBYNAME" = "TEST_ADMIN" AND "FIRSTNAME" = "John" AND "TYPEID"="1900000000"
I want to use a loop because there can be up to 15 options in the json object. and the if statement would just not do.
Plz help.

What you can do with that object, I can't tell you because I don't know what it can or can't do. What's its API? Where does it come from?

Similar Messages

  • How do I: Loop through Application objects

    How would I loop through the application object?  My goal is to see if the object is a label and change its font size.
    pseudocode would look like this:
    function setsize(change int) {
      for each obj in application {
        if obj is of type label {
          set font size to font size + change
    Once I got that working, I'd add other objects that display text.  The "change" would be a number to increase (positive) or decrease (negative) the size.
    Thanks,
    Jerry

    I have this:
              <mx:HBox id="resultTextBox"
                  width="100%"
                  verticalScrollPolicy="off" horizontalScrollPolicy="auto">
                  <mx:Label id="resultPotentialResultsLabel"
                      text="Food Stamp potential eligibility for household, estimated monthly benefit amount "
                      styleName="textNormal"
                      toolTip="Results message"
                      tabIndex="200" tabEnabled="true"  fontSize="40"/>
                  <mx:Text id="resultPotentialResultsData"
                      styleName="resultNumberNormal"
                      toolTip="Final results"
                      tabIndex="202" tabEnabled="true" />
              </mx:HBox>
    When I expand the font size it pushes the "resultPotentialResutsData" to limbo.  I tried adding the horizonal scroll bar to allow the user to still see the results,  The scroll doesn't appear.
    1) is there a way to get the box to expand to fix the content?
    2) is there a way to get the scroll bar to appear when needed?
    3) is there a way to wrap the text (in this case the second field) in the HBox?

  • Looping through serialized objects?

    I have made a program which stores the game score such as seen 3d pinball. I know how to store then but I don't know how to loop through all records so that I can store them in one single array so that I can perform diffenent operations on that array.
    such I should arrange them and find out the top five scorer. Give me some valueable hints.

    Demo:
    import java.io.*;
    import java.util.*;
    public class Example implements Serializable {
        private static final long serialVersionUID = 1;
        private String text;
        public Example(String text) {
            this.text = text;
        public String toString() {
            return text;
        public static void main(String[] args) throws IOException, ClassNotFoundException {
            List<Example> list = new ArrayList<Example>();
            Collections.addAll(list, new Example("hello"), new Example("world"));
            File file = new File("temp.dat");
            ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file));
            out.writeObject(list);
            out.flush();
            out.close();
            ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
            List<Example> input = (List<Example>) in.readObject();
            in.close();
            System.out.println(input);
    }

  • Looping through an objects children

    This post is related to another post I have in the forums:
    "Dynamically adding containers".
    However, I am using an object (note this object can change -
    is dynamic):
    [CODE]
    [Bindable]
    public var dashboardDP:Object =
    {item:"dashboard", children: [
    {item:"vbox", id:"vbox 1", children: [
    {item:"panel", id:"panel 1", children: [
    {item:"hbox", id:"hbox 1", children: [
    {item:"view" id:"view 1"},
    {item:"view" id:"view 2"},
    {item:"view" id:"view 3"}
    {item:"hbox", id:"hbox 2", children: [
    {item:"view" id:"view 4"},
    {item:"panel", id:"panel 2", children: [
    {item:"vbox", id:"vbox 2", children: [
    {item:"view" id:"view 5"},
    {item:"view" id:"view 6"},
    [/CODE]
    And I want to loop through every child in this object but am
    struggling to do so :(
    e.g. the following loop will ony return the first child of
    the object:
    [CODE]
    for(var i:int=0; i<dashboardDP.children.length; i++)
    // some code.....
    [/CODE]
    I want to advance this loop so that it "drills" into and
    retrieves / reads every child and sub child of each parent etc.....
    Is this possible???
    Any help would be much appreciated on this one.
    Thanks in advance,
    Jon.

    Hi "xtempore" thanks for the fast reply!!!
    Just off the top of my head... I am using an Object type for
    "dashboardDP".
    Will this work as in your example to loop through and get all
    the children?
    I notoce you are using a type UIComponent and referencing
    UIComponent.children - will this work?
    I have train but am getting errors... with the line:
    for each (var c: UIComponent in comp.children) {
    when trying to access the ".children"
    Could you please expand?
    Thanks again,
    Kind Regards,
    Jon

  • Accessing BIA through Business Objects - read from Query or InfoCube

    Hi All,
    I've a BObj/BIA question, some similar threads have been posted....
    With a Business Objects front-end, I understand that BIA can be used to access Indexed InfoCube data, and reduce the data manager portion of the overall runtime.
    My question relates to the options of a)Business Objects reading data defined in Queries, or b)BO reading the data from the InfoCubes.
    So my question is:
    a) Is there any difference/benefit in using one option over the other? (queries Vs InfoCubes directly)
    b) Will both methods access the required data through the BIA if it (the data) is available there and indexed?
    Thanks for the help,
    Mk.

    Hello Michael,
    both methods will use BIA. We recommend to use queries since they typically limit the selection criteria through variables and give you the possibility to use restricted and calculated key figures. With direct InfoCube access you run the risk that users try to read the complete InfoCube.
    Regards,
    Marc
    SAP NetWeaver RIG

  • Looping through objects - testing links

    Hi
    I have a script that moves all instances of a linked object according to user defined X,Y values.
    In order to do this, I need to loop through all objects with links
    What is the best way to do this?
    As of now, this is what I am doing:
    var g = myDoc.allGraphics;
    for (var i=0; i<g.length; i++) {
         if (g[i].itemLink.name == USER_LINK) {
              g[i].parent.move(undefined, [USER_X, USER_Y]);
    It works well, however I ran into some problems where link was null
    Also, is it always the graphic that is linked, or can its parent be linked as well?
    If not, then I can just condition that if itemLink == null - continue
    Any advice and guidance would be much appreciated
    Thanks
    David

    It works well, however I ran into some problems where link was null
    if (g[i].itemLink && g[i].itemLink.name == "USER_LINK")     //     should be enough
    Also, is it always the graphic that is linked, or can its parent be linked as well?
    Graphic can be linked ==> itemLink !=null and itemLink.status can vary
    or pasted ==> itemLink == null.
    As far as I know graphic.parent can not be linked.
    However not every linked graphic.parent can be moved. I e. those one which are anchored with
    AnchorPosition.INLINE_POSITION and AnchorPosition.ABOVE_LINE
    Above case can be a source of error as well.
    Consider also locked object or locked entire layers.
    Jarek

  • Loop through CSV to create XML

    Hello all, first and foremost I want to apologize if this has been answered somewhere, but I am looking to do the following:
    I have 500 records I need put in XML format. The records are currently in CSV format. I can use curl to upload a record in XML format using our applications API. I was under the impression that I could generate 1 large XML file and upload the entire group.
    I have a script that will read in data from a CSV and output it to a file in XML format. I got the script the way I thought I needed it working, which was to create a new xml file, append a line to it, then loop through the csv and echo my string repeatedly inputing the variables from the CSV file. I could then upload the XML file where I needed it.
    As it turns out, it seems the API will only allow me to upload 1 record at a time. (ALMOST pointless IMO.) So what I am looking to do is change the way the script loops through the CSV file, and instead of creating 1 large file, I would like the script to loop through the CSV one line at a time, create the XML file of only 1 record, upload it using curl, delete itself (or its contents) and repeat that process throughout the entire CSV file.
    I am just getting familiar with loops, so Im not sure how I would even start this process, or even word what I want properly to search google. (Which I have been for the last two days, thats how I frankenstiened what I have below. Any help would be greatly appreciated.
    The script is as follows:
    #!/bin/bash
    echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' >> xmldata.xml
    #:Read variables from XMLInput.csv:#
    while read inputline;do
    line0="$(echo $inputline | cut -d, -f1)"
    line1="$(echo $inputline | cut -d, -f2)"
    #:Set auto increment ID:#
    idAdd0=$((idAdd0 +1))
    #:removes trailing alpha characters leaving only the IP address:#
    cutLine0=${line0//[^0-9.]/}
    #:Strips trailing octet and appends .1:#
    startIP=`echo $cutLine0 | sed 's/.[0-9]*$/.1/'`
    #:Strips trailing octet and appens 254:#
    endIP=`echo $cutLine0 | sed 's/.[0-9]*$/.254/'`
    #:echos line to txt file as XML:#
    echo "<network_segment><id>"$idAdd0"</id><name>$line0</name><starting_address>$startIP</starting_address><ending_address>$endIP</ending_address><distribution_point/><url/><netboot_server/><swu_server/><building>$line1</building><department/><override_buildings>false</override_buildings><override_departments>false</override_departments></network_segment>" >> xmldata.xml
    done < XMLInput.csv
    exit 0

    What I ended up doing was having the script create 500 separate XML files in a folder by adding my auto increment variable to the XML file name,
    then curling each file as a separate entry. A litte dirtier than I wanted, but in the end, I didn't have to manually enter 500 subnets
    and define there locations in a website. Job Done.
    Script if interested:
    #!/bin/bash
    #:Read variables from XMLInput.csv:#
    while read inputline;do
    line0="$(echo $inputline | cut -d, -f1)"
    line1="$(echo $inputline | cut -d, -f2)"
    echo
    #:Set auto increment ID:#
    idAdd0=$((idAdd0 +1))
    #:removes trailing alpha characters leaving only the IP address:#
    cutLine0=${line0//[^0-9.]/}
    #:Strips trailing octet and appends .1:#
    startIP=`echo $cutLine0 | sed 's/.[0-9]*$/.1/'`
    #:Strips trailing octet and appens 254:#
    endIP=`echo $cutLine0 | sed 's/.[0-9]*$/.254/'`
    #:echos line to txt file as XML:#
    echo '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'"<network_segment><id>"$idAdd0"</id><name>$line0</name><starting_address>
    $startIP</starting_address><ending_address>$endIP</ending_address><distribution_point/><url/><netboot_server/><swu_server/><building>$line1</building>
    <department/><override_buildings>false</override_buildings><override_departments>false</override_departments></network_segment>" >> xmldata$idAdd0.xml
    #:upload XML file to JSS:#
    `curl -k -v -u account:Password https://server address/JSSResource/networksegments/name/SegmentName -T "xmldata$idAdd0.xml" -X POST`
    done < XMLInput.csv
    exit 0

  • Looping through business partners

    I need to run a query that shows which BPs have NOT had a recent delivery.  Therefore, I am searching for values not present.  I have decided to run a subquery pulling up all deliveries within the last month and then looping through all BPs to see if they are in that query.  If not, I want to display their name as part of the result.  I am not sure how to loop through BPs in SQL using Query Generator.  Any idea of syntax?
    Thank you in advance for you help!
    Jacquie

    I'm not sure about this, but I guess that you can't set parameters in that second SELECT at all.
    This works:
    SELECT T0.CardName FROM OCRD T0
    Where T0.CardCode Not in
    (SELECT T0.CardCode FROM OINV T1
    WHERE datediff(Day,T1.DocDate, getdate())<0)
    This doesn't: (I changed only: getdate())<'[%0]')
    SELECT T0.CardName FROM OCRD T0
    Where T0.CardCode Not in
    (SELECT T0.CardCode FROM OINV T1
    WHERE datediff(Day,T1.DocDate, getdate())<'[%0]')
    Regarding your SQL. From the syntax point of view:
    - include a space between "NOT_in"
    - maybe you should eliminate T0.DocDate from the second SELECT
    HTH
    Juha

  • Loop through Query String in ASP

    Hi,
    I am new to ASP and am trying to loop through values in a
    query string
    separated by a comma, for example:
    /site/search/results.asp?ids=19736a,20248a,14952a,19956a
    I need to construct SQL from this something like
    SELECT * FROM MyTable WHERE
    ID = 19736a OR
    ID = 20248a OR
    ID = 14952a OR
    ID = 19956a
    I am just unsure on how to separate all the values from the
    query string.
    Thanks for your advice.

    Oh, in the example below there is no space between the id
    numbers in the
    querystring.
    eg. ids=1,23,456,2
    If you do have spaces then you need to adjust the split
    accordingly
    eg. ids=1, 23, 456, 2
    you would use myIdArray=split(idStr,", ")
    note the space after the comma.
    just make sure you always use the same format in your
    querystring
    Justin
    "Justin Reid" <[email protected]>
    wrote in message
    news:e6osem$dfj$[email protected]..
    > You need to create an array of ids and then add them to
    your SQL.
    > Something like:
    > <%
    > If Request.QueryString("ids") <> "" Then
    > Dim idStr, cnt, varID
    > 'get the string of id'
    > idStr = Request.QueryString("ids")
    > 'create the array
    > myIdArray=split(idStr,",")
    > cnt=0
    > 'loop though the array and add to a new string
    > for i=o to ubound(myIdArray)
    > If cnt > 0 Then varID = (varID & " OR")
    > varID = (varID & " id = " & cStr(myIdArray(i)))
    > cnt=cnt+1
    > next
    > End If
    > %>
    >
    > Then simply add you new SQL segment to your recordset.
    > Something like
    >
    > SELECT * FROM MyTable WHERE" + Replace(varID, "'", "''")
    + "
    >
    > Hope that helps
    >
    > Justin
    >
    > "Shaun" <[email protected]> wrote in
    message
    > news:e6ole1$56v$[email protected]..
    >> Hi,
    >>
    >> I am new to ASP and am trying to loop through values
    in a query string
    >> separated by a comma, for example:
    >>
    >>
    /site/search/results.asp?ids=19736a,20248a,14952a,19956a
    >>
    >> I need to construct SQL from this something like
    >>
    >> SELECT * FROM MyTable WHERE
    >> (
    >> ID = 19736a OR
    >> ID = 20248a OR
    >> ID = 14952a OR
    >> ID = 19956a
    >> )
    >>
    >> I am just unsure on how to separate all the values
    from the query string.
    >>
    >> Thanks for your advice.
    >>
    >
    >

  • GeoRaster- loop through each cell and execute spatial query?

    Hi,
    So what I want to do is, to loop through each cell in a raster and get the ground x,y coordinates. Then based on the x,y value I want to execute a query on a vector layer.
    My question is, how do I find each cell coordinate? That I will then use with SDO_GEOR.getModelCoordinate to get the ground coordinates, query vector, etc...
    Thanks.

    I am not sure what you want to do. Why not just use the spatial extent of the GeoRaster object?
    Anyway, say sdo_geor.getULTCoordinate returns (r0, c0, b0), and sdo_geor.getSpatialDimSizes returns (rows, cols). The range of the cell coordinates (at the original image level) are:
    row: r0 -- r0+rows-1
    column: c0 -- c0+cols-1
    Regards,
    Terry

  • Passing Flash Vars Through Query Strings and JS

    I'm trying to get a particular video to play in a flash ad
    when a particular query string is clicked. I can't get it to work
    and would appreciate any help that you can provide. The ad plays
    but the movies don't show when the query string is clicked or when
    you click on objects in the movie that are supposed to populate a
    movie. Here's the code I've been trying to use:

    Thanks for the advice, I have tried Javascript to resolve the
    problem. In response to the <object> tag missing, There is
    one I just included a snippet of the html code sorry for the
    confusion. Due to deadlines I abandoned the functionality of the
    script and "dumbed" down the script. Thank you again for the help

  • Question on how to loop through a variable amount of objects

    I have a csv file which I am parsing with powershell and it works perfectly. I would like to speed it up. Currently, I call a line that is customized for each groups list of subnets.
    I have about 30 groups.
    Some groups have one subnet, some have 5 subnets.
    I want to set up some sort of loop to parse everything while executing a single Import-CSV. Currently I call Import-CSV once per group. It takes me about 2-4 minutes to parse the entire file depending on the speed of the machine.
    The csv file has about 30,000 rows. I am not concerned about running out of resources. This is as much a learning challenge as a desire to make better powershell scripts.
    Below is a portion of the one liner that would parse the entire csv file looking only for those items that match, and writing them out to that groups specific csv file.
    Example #1
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.1.*" -or $_."IP Address" -Match "^192.2.*" -or $_."IP Address" `-Match "^192.3.*"  .....}| do more stuff...
    Example #2
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.7.*" ....}| do more stuff...
    The example above is just a snippet from code that works perfectly.
    The problem I am asking for help with is, when I loop through the items I am matching against (subnets), if one group has 3 items to match against, another has 1, another has 7, how do I set up such a loop?
    Am I using some sort of 'while'  $_."IP Address" or...?
    Do I create a big 30,000 array (Does PS even use arrays?)
    I would love to know what this type of looping is called, and what I can read with examples on how to understand approaching this challenge..
    Thank you for any help.
    -= Bruce D. Meyer

    The reason for the parsing (I thought I explained it, must have been too vague) is I have about 30 agencies in a csv file.
    Each agency can be determined by their subnet(s) and domain(s)
    I need to put all lines in the csv relating to each agency in their own separate csv file to distribute to them so I am not sharing agency 'A' info with the other 29 agencies.
    I get the regex comment. Thank you. For some reason I am rather hesitant to use PCRE under windows. I'll see how it works.
    Your comment on "Reloading a large file repeatedly takes more time", is the exact reason why I asked the question. I want to get away from that.
    I appreciate your quick reply, I think your example will work nicely. 
    -= Bruce

  • Reader Hive query - Cannot deserialize the current JSON object

    Hi all,
    I am trying to run a Reader module in MLStudio with a Hive query but it fails with Error 0000: Internal error.
    In the output log I see this error:
    [ModuleOutput] DllModuleHost Error: 1 : Program::Main encountered fatal exception: Microsoft.Analytics.Exceptions.ErrorMapping+ModuleException: Error 0000: Internal error ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'Newtonsoft.Json.Linq.JToken' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
    [ModuleOutput] To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
    [ModuleOutput] Path 'FileStatus.length', line 3, position 14.
    But I don't see any configuration to change any JSON settings.
    What am I doing wrong? Can anyone help me?
    Thanks,
    Csaba
    PS: Using the Hive Editor I can select from my table without any problems.

    Can you let us know if you are still encountering this error? It doesn't look the error is due to user error.

  • Upload XLS File, Loop through rows query a DB

    What I would like to do is enable the user to upload an excel
    spreadsheet with one column and many row of IP's. Then put the ips
    in a list or array and loop through the list and query a table to
    get the IPs that match the list.
    Any help would be greatly appreciated.

    We have some similar apps except that, instead of uploading a
    file, the users copy and paste the column into a text area. Then we
    do this:
    <!--- First, replace carraige returns (chr(13)) and line
    feeds (char(10)) with commas --->
    <cfset
    hscnumbers=Replace(form.hscnumbers,chr(13)&chr(10),",","ALL")>
    <!--- remove last comma, if commas exist (there may be
    only one hsc number) --->
    <cfif find(",", hscnumbers) gt 0 and right(hscnumbers, 1)
    is ",">
    <cfset hscnumbers = left(hscnumbers, len(hscnumbers) -
    1)>
    </cfif>
    And then we have a list to send to the db.

  • Pass Variables into AS3 through Query String?

    Man! I've been searching ferociously and can't seem to find a solution that works for me. I am trying to pass variables via query string on a PHP page to Flash, and then have the swf add movie clips to the stage depending on the information it receives.
    Here is what the PHP outputs:
    swfobject.embedSWF("flash/detailScore.swf?a=0-0&b=0-0&c=30-54&d=30-20&e=42-18", ...
    And here is my AS3 code:
    function loaderInfoSh(e:Event):void{
    var myQueryStrings=this.loaderInfo.parameters;
    a = myQueryStrings.a;
    b = myQueryStrings.b;
      c = myQueryStrings.c;
    d = myQueryStrings.d;
    e = myQueryStrings.e;
    addTheResults(a,1);
    addTheResults(b,2);
    addTheResults(c,3);
    addTheResults(d,4);
    addTheResults(e,5);
    this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfoSh);
    The addTheResults function takes the coordinates, adds a MC instance to the stage and positions it accordingly.
    var colorMCArray:Array = new Array();
    function addTheResults(val,colnum:Number){
    if(val == null){val = "52-46";} // so I can test it locally
    var daColor:String;
    switch (colnum){
    case 1:
    daColor = "f3951c";
    break;
    case 2:
    daColor = "74b47d";
    break;
    case 3:
    daColor = "436494";
    break;
    case 4:
    daColor = "9b74ac";
    break;
    case 5:
    daColor = "b43d44";
    break;
    var dash:int = val.indexOf("-");
    var lateral = val.slice(0,dash);
    var vertical = val.slice(dash+1);
    lateral --;
    vertical --;
    // adding the MC instance
    var comm:tileB = new tileB();
    comm.name = "comm"+colnum;
    addChild(comm);
    colorMCArray[colnum] = comm;
    //Change the color
    var colorTransform:ColorTransform = colorMCArray[colnum].transform.colorTransform;
    var thiscolor = "0x"+daColor;
    colorTransform.color = thiscolor;
    colorMCArray[colnum].transform.colorTransform = colorTransform;
    colorMCArray[colnum].x = 5;
    colorMCArray[colnum].y = 536;
    colorMCArray[colnum].x += (lateral * 9);
    colorMCArray[colnum].y += (vertical * 9)*-1;
    colorMCArray[colnum].addEventListener(MouseEvent.MOUSE_OVER, btnro);
    colorMCArray[colnum].addEventListener(MouseEvent.MOUSE_OUT, btnrout);
    I don't know what I'm doing wrong here.

    Was this the "e" in the code below you were pertaining to as the culprit? "e" is not a keyword. It's just the shortcut for the word "event" for the variable name of type Event which is the Event object that triggered the call of function loaderInfoSh. In your code you assigned e = myQueryString.e which should have given you a type mismatch error.
    function loaderInfoSh(e:Event):void{
    var myQueryStrings=this.loaderInfo.parameters;
    a = myQueryStrings.a;
    b = myQueryStrings.b;
      c = myQueryStrings.c;
    d = myQueryStrings.d;
    e = myQueryStrings.e;
    addTheResults(a,1);
    addTheResults(b,2);
    addTheResults(c,3);
    addTheResults(d,4);
    addTheResults(e,5);
    this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfoSh);

Maybe you are looking for