Creating an Address / Phone Array.

froliol
2011-10-13
2013-05-28
  • froliol

    froliol - 2011-10-13

    Greetings All, I have been trying in vain to create a simple JSON object for a patient that has a name, and address array and a phone array that allows for multiple phones.  Let me demonstrate what I want:

    {
        "firstName": {
            "string": "c2-firstName"
        }
        "addresses": {
            "array": [
                {
                    "addressLine1": {
                        "string": "c2-addrline2"
                    }
                }
            ]
        },
        "phones": {
            "array": [
                {
                    "phoneType": {
                        "string": "c2-phoneType"
                    },
                    "phone": {
                        "string": "c2-phone"
                    }
                },
                {
                    "phoneType": {
                        "string": "c3-phoneType"
                    },
                    "phone": {
                        "string": "c3-phone"
                    }
                }
            ]
        } }
        }
    }

    This is a scaled back version of the Json I need to create, however it demonstrates my sticking points mainly the successful implementation of an address array and a phone array that allows for multiple phone numbers.

    Any and all help would be greatly appreciated.

    Cheers, Louis.

     
  • froliol

    froliol - 2011-10-13

    Not an ounce of love on this one folks? Any relevant advice, help, anything would be great!

     
  • James Sumners

    James Sumners - 2011-10-13

    You haven't said what your actual problem is or even what you have tried. How are we supposed to help?

     
  • froliol

    froliol - 2011-10-13

    Ahh Excellent! Mr. Summers I want to create a Json object that takes on that form I have indicated.  In short I would like to see the PL/JSON code that I would use to create the very Json objects I have provided.  I have studied ex5.sql but for the life of me can't get from that to the Json above.  Do you think you could demonstrate how I go about achieving this task?

    I really appreciate your getting back to me on this.

    Louis.

     
  • James Sumners

    James Sumners - 2011-10-13

    There is no way to answer your "question" without knowing what your source data looks like. That is, I have no idea what tables you have or what is the structure of those tables. Sure, I could write a procedure that generates that specific JSON, but that is going to be no help to you what-so-ever. The best I can do, with the information given, is point you to this article - http://jrfom.com/2011/01/26/pljson-library/.

     
  • froliol

    froliol - 2011-10-14

    Mr. Summers, please forgive my not being more clear.  Having an example of how to generate the structure is what I want.  I was thinking that all the values could be treated like a constant, e.g.) "c2-firstName".  Once I know how to manipulate the two methods (json, and json_list) to get the array of arrays the rest is trivial for me.  Yes, I ultimately will be querying tables to gather the data, however until I am confident that I can put that structure together I am simply stuck.  I will look at your link and see if that helps but if you could be so kind as to show me the pl/sql coupled with the api calls to generate that structure I would be most grateful. 

    Cheers and thanks for your patience and time.

    Louis.

     
  • froliol

    froliol - 2011-10-14

    Also, I just realized I have been spelling your name wrong. I have to admit that I hate it when people can't get a name right.  With that said, Mr. Sumners, I apologize for getting your name wrong.

    Louis

     

Log in to post a comment.