Streamline CLI (snake_case) and Connect (camelCase) JSON

franklin
franklin
Community Member

Would it be possible to streamline the JSON format between the CLI (snake_case) and Connect SDK (camelCase) e.g.

op item get XXX --format json
{
  "id": "",
  "title": "",
  "version": 1,
  "vault": {
    "id": ""
  },
  "category": "",
  "last_edited_by": "",
  "created_at": "",
  "updated_at": "",
  "sections": [
    {
      "id": "",
      "label": ""
    }
  ],
  "fields": [
    {
      "id": "",
      "type": "",
      "purpose": "",
      "label": "",
      "value": "",
      "entropy": 0,
      "password_details": {
        "entropy": 0,
        "generated": true,
        "strength": ""
      }
    },
    {
      "id": "",
      "type": "",
      "purpose": "",
      "label": "",
      "value": ""
    }
  ]
}

vs e.g. Go SDK

type Item struct {
    ID    string `json:"id"`
    Title string `json:"title"`

    URLs     []ItemURL `json:"urls,omitempty"`
    Favorite bool      `json:"favorite,omitempty"`
    Tags     []string  `json:"tags,omitempty"`
    Version  int       `json:"version,omitempty"`
    Trashed  bool      `json:"trashed,omitempty"`

    Vault    ItemVault    `json:"vault"`
    Category ItemCategory `json:"category,omitempty"` // TODO: switch this to `category`

    Sections []*ItemSection `json:"sections,omitempty"`
    Fields   []*ItemField   `json:"fields,omitempty"`
    Files    []*File        `json:"files,omitempty"`

    LastEditedBy string    `json:"lastEditedBy,omitempty"`
    CreatedAt    time.Time `json:"createdAt,omitempty"`
    UpdatedAt    time.Time `json:"updatedAt,omitempty"`
}

1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided

Comments

  • Hey @franklin, thank you bringing this to our attention!

    I do agree that having the same representation for an item across different products is indeed useful.
    Can you please give me some more details about your use-case, and how would this benefit your workflow?
    Thank you, looking forward to hearing from you!

    Best,
    Horia

  • franklin
    franklin
    Community Member

    Hi @Horia.Culea_1P,

    we're currently preparing a pull request to extend your terraform 1password provider which can also use the cli.

    But doing so atm forces us to duplicate some code provided by the connect SDK just to get the json mapping right.

    Greetz,

    Kevin

  • Thank you for the follow up!

    We have an internal ticket tracking improvements over json keys currently under work.
    I'll make sure to follow up as soon as we have something to share.

    Best,
    Horia

This discussion has been closed.