Results 1 to 5 of 5

Thread: JSON Expected BEGIN_ARRAY

  1. #1
    Join Date
    Feb 2009
    Location
    Somerset, PA
    Posts
    532

    Default JSON Expected BEGIN_ARRAY

    Hello there,

    I am having a problem with my JSON format.
    the service is expecting an array and I must be sending as an object.

    From the service I get this message:

    Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $;


    I am making he REST call with this:
    Code:
    Get HttpVerbAddrRequest of oHttp sPath pReq iSize False sVerb to iOK
    Get HttpVerbAddrRequest of oHttp sPath pReq iSize False sVerb to iOK

    Is there a way to send as an array?

    Thanks for any direction!

    Henry

  2. #2
    Join Date
    Feb 2009
    Posts
    5,470

    Default Re: JSON Expected BEGIN_ARRAY

    How are you building your JSON ?

    If you are using the built in 19.1 classes see Mikes post here

    https://support.dataaccess.com/Forum...lue#post336827
    Success consists of going from failure to failure without loss of enthusiasm - Winston Churchill

  3. #3
    Join Date
    Feb 2009
    Location
    Somerset, PA
    Posts
    532

    Default Re: JSON Expected BEGIN_ARRAY

    hi there,
    Oh yes thanks for the link.
    We are still using 19.0.

    I am buidling my JSON as I have below:

    Code:
     Move "123456"            to ltemployee.ProviderIdentification.ProviderID   
            Move "111111"               to ltemployee.ProviderIdentification.ProviderQualifier   
            Move "EmployeeCustomID"     to ltemployee.EmployeeQualifier
            Move "7777"                 to ltemployee.EmployeeIdentifier
            Move "0"                    to ltemployee.SequenceID
            Move "123456789"            to ltemployee.EmployeeSSN
            Move "Henry"                to ltemployee.EmployeeFirstName
            Move "Egal"                 to ltemployee.EmployeeLastName
            Move "henry@horizon-is.com" to ltemployee.EmployeeEmail
            
            
            Get Create (RefClass(cJsonObject))  to hojsonPath
            Send DataTypeToJson of hojsonPath ltemployee
    I will not be moving to 19.1 yet so I will have to research.

    Thanks!
    Henry

  4. #4
    Join Date
    Feb 2009
    Posts
    5,470

    Default Re: JSON Expected BEGIN_ARRAY

    If the whole thing need to be in array then just declare

    whateverstruct[] ltemployee

    Move "111111" to ltemployee[0].ProviderIdentification.ProviderQualifier

    etc
    Success consists of going from failure to failure without loss of enthusiasm - Winston Churchill

  5. #5
    Join Date
    Feb 2009
    Location
    Somerset, PA
    Posts
    532

    Default Re: JSON Expected BEGIN_ARRAY

    Hi there,
    Yes that is it.
    I had tried to putting a [ at the beginning and ] a the end of the JSON and that worked.
    Making my variable a struct did the same thing and that is the correct way.

    Thanks so much for your help!!

    Greatly appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •