-1

I am trying to generate a label with a multiline address.... the docs say the occurrence of AddressLine can appear three times. however this is invalid json and I am not sure how to go about it in GO.

Address: &ShipmentAddress{
        AddressLine: `Street Value \n Suite122`
        City:              "City",
        StateProvinceCode: "State",
        PostalCode:        "ZIP",
        CountryCode:       "COUNTRY",
    },

The above value does not work.

Docs

dev
  • 39
  • 8
  • Thats not the right way to define a multi-line string literal in Go. The _raw_ string literal form involving ``, does not interpret any of the escaped sequences. Use the interpreted string literals form involving double quotes `".."`, i.e. `"Street Value \n Suite122"` – Inian Apr 21 '22 at 03:41
  • tried that and UPS doesn't parse \n apparently. – dev Apr 21 '22 at 04:22
  • Can you post a minimal example of the stuff (APIs/input JSON) you are dealing with? – Inian Apr 21 '22 at 04:23
  • edited the post with the docs. this is what UPS expects but from my knowledge you can't have 3 elements that are the same with JSON – dev Apr 26 '22 at 19:58

2 Answers2

0

https://go.dev/play/p/10SZ63FSKAf

    fmt.Println(`This is a
multiline
string.`)
    fmt.Println("And this is a\nmultiline\nstring too!")
thrownew
  • 119
  • 4
  • tried both and UPS doesn't accept those as multiline. the problem I think lies in their design of the api. they expect AddressLine to appear three times as separate elements, so my guess is a SOAP Api was converted to a REST and they never changed the system to match proper JSON. – dev Apr 21 '22 at 15:20
0

When the docs says it supports 3 occurrences they mean that it can be either just a string like in your example or an array up to 3 string elements. ["123 Street", "Room 5"]

Would get a label of:

123 Street Room 5

nerz
  • 1
  • Could you give more information? – hkulekci Feb 18 '23 at 13:21
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 18 '23 at 13:21