Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

DataRow attributes are omitted when the row is converted to JSON #144

Closed
hyyan opened this issue Apr 23, 2019 · 2 comments
Closed

DataRow attributes are omitted when the row is converted to JSON #144

hyyan opened this issue Apr 23, 2019 · 2 comments
Assignees

Comments

@hyyan
Copy link
Member

hyyan commented Apr 23, 2019

DataRow attributes should be part of the row when it is converted to JSON

The following programme shows how the row attributes are missings

My suggestion :

  1. Add attrs object to the final JSON (recommended)
  2. Copy the row attributes to each field

Programm:

    declare SqlQueryBC sbc!
    sbc! = new SqlQueryBC(BBjAPI().getJDBCConnection("CDStore"))
    rs! = sbc!.retrieve("SELECT  * FROM CDINVENTORY")

    rs!.get(0).setAttribute("BGCOLOR","Black")
   
   print rs!.get(0).toJson()

Output:

[
   {
      "CDNUMBER":"000001",
      "TITLE":"\u003Cb\u003EMississippi Blues\u003C/b\u003E",
      "ARTIST":"John Hurt \u0026 The Ramblers",
      "LABEL":"Blind Pig",
      "PLAYINGTIME":"72",
      "RECORDINGTYPE":"AAD",
      "MUSICTYPE":"Blues",
      "BINLOCATION":"N123",
      "NUMBEROFTRACKS":12,
      "ONHAND":55,
      "COST":5.99,
      "RETAIL":12.99,
      "meta":{
         "CDNUMBER":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "TITLE":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "ARTIST":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "LABEL":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "PLAYINGTIME":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "RECORDINGTYPE":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "MUSICTYPE":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "BINLOCATION":{
            "ColumnType":"12",
            "EDITABLE":"1"
         },
         "NUMBEROFTRACKS":{
            "ColumnType":"2",
            "EDITABLE":"1"
         },
         "ONHAND":{
            "ColumnType":"2",
            "EDITABLE":"1"
         },
         "COST":{
            "ColumnType":"2",
            "EDITABLE":"1"
         },
         "RETAIL":{
            "ColumnType":"2",
            "EDITABLE":"1"
         }
      }
   }
]
@StephanWald
Copy link

both 1. and 2., or either/or?

@hyyan
Copy link
Member Author

hyyan commented May 2, 2019

@StephanWald either, first one recommended

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants