4
lopu
2y

Company A (mine) is building a site for company B, company B employs company C to manage their inventory database, company C exports inventory as JSON to company A, company C says, this field (SKUs) will be an object (skus = {...}) when it only has 1 value, but an array (skus = [{}, {}, ...]) when there are multiple SKUs, company A (me) tells company B to tell company C to ensure it's always an array.... company B is scared of company C and company A (me) is always cleaning up company C's shit

Comments
  • 1
    For simplicity's sake lets make it always an object: Properties firstOfTwo and secondOfTwo for exactly two SKUs.
    Properties first, middle, last for three SKUs.

    For more than three SKUs:
    Properties like for two to three SKUs, but the values are objects of SKUs like outlined above.
    This tree structure should be able to accomodate any amount of SKUs there could possibly be.

    No need to thank me or pay royalties, i am known for my straightforward and simple data structures and am happy to help.
  • 0
    @Oktokolo lmfao you get it xD
  • 0
    Some JSON serializers behave this way by default. I'm guessing that's why you're getting this mess - devs were too lazy to reconfigure the serializer.

    I can't point a finger, but I'm 100% certain I've been bit by that myself. From the API developer's perspective (i.e. I was returning {} if only 1 item, and {}[] if multiple). Then I found I can disable this nonsense... I *think* it had something to do with Spring and whatever serializer it was using in that version
  • 0
    I have worked with similar company issues. Only for me the variable names were slightly different for each API call, eg. companyID, compId, CompID, Companyid, company_id
  • 0
    @ojt-rant
    "We have two company ID properties.
    The first contains the company ID formatted as bitmap with prerendered glow ready for display on the page.
    The second contains the company ID hashed for use as a search key."
  • 0
    @Oktokolo not to be confused with the "company" DB table, of course....company.id :)
Add Comment