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

The json-encoder in go escapes < > making it hard to read expressions #346

Closed
sublibra opened this issue Jun 27, 2019 · 2 comments · Fixed by #364
Closed

The json-encoder in go escapes < > making it hard to read expressions #346

sublibra opened this issue Jun 27, 2019 · 2 comments · Fixed by #364
Labels
bug Something isn't working

Comments

@sublibra
Copy link
Collaborator

The json-encoder used in corectl escapes common characters such as < > before sending this to the engine. It is correct json and engine handles this correctly and the presentation for the user mostly unescapes before sending back to the users. In some case it isn't and for reading purposes, especially in set expressions, this makes it really hard to read.

Consider changing the presentation of the json output to unescape the characters in following cases (may be more):

  • unbuild output
  • title, label etc in dim, measures

Example:

{
  "qInfo": {
    "qId": "dim-1",
    "qType": "dimension"
  },
  "qDim": {
    "qLabel": ">><< !#€%&/()=?",
    "qFieldDefs": ["({$<Type={'feature'}>} Size)"]
  },
  "qMetaDef": {
    "title": ">><< !#€%&/()=?"
  }
}

engine communication

--> {"jsonrpc":"2.0","delta":false,"method":"SetProperties","handle":2,"id":4,"params":[{"qInfo":{"qId":"dim-1","qType":"dimension"},"qDim":{"qLabel":"\u003e\u003e\u003c\u003c !#€%\u0026/()=?","qFieldDefs":["({$\u003cType={'feature'}\u003e} Size)"]},"qMetaDef":{"title":"\u003e\u003e\u003c\u003c !#€%\u0026/()=?"}}]}

corectl dimension layout dim-1

{
  "qInfo": {
    "qId": "dim-1",
    "qType": "dimension"
  },
  "qMeta": {
    "privileges": [
      "read",
      "update",
      "delete",
      "exportdata"
    ],
    "title": "\u003e\u003e\u003c\u003c !#€%\u0026/()=?"
  },
  "qDim": {
    "qGrouping": "N",
    "qFieldDefs": [
      "({$<Type={'feature'}>} Size)"
    ],
    "qFieldLabels": [],
    "qLabel": "\u003e\u003e\u003c\u003c !#€%\u0026/()=?",
    "qLabel": "\u003e\u003e\u003c\u003c !#€%\u0026/()=?"
  },
  "qDimInfos": [
    {
      "qApprMaxGlyphCount": 0,
      "qCardinal": 0,
      "qTags": []
    }
  ]
}

unbuild output:

[
  {
    "qInfo": {
      "qId": "dim-1",
      "qType": "dimension"
    },
    "qDim": {
      "qGrouping": "N",
      "qFieldDefs": [
        "({$\u003cType={'feature'}\u003e} Size)"
      ],
      "qFieldLabels": [],
      "qLabel": "\u003e\u003e\u003c\u003c !#€%\u0026/()=?"
    },
    "qMetaDef": {
      "title": "\u003e\u003e\u003c\u003c !#€%\u0026/()=?"
    }
  }
]
@wennmo
Copy link
Member

wennmo commented Jun 28, 2019

Can be set on the encoder, but then we need reuse the encoder across all commands.
https://golang.org/pkg/encoding/json/#Encoder.SetEscapeHTML

@wennmo wennmo added the bug Something isn't working label Jun 28, 2019
@glooms
Copy link
Contributor

glooms commented Jul 19, 2019

This is bug is due to enigma-go, not a corectl. The data on our part in the above example is:

{
  "qInfo": {
    "qId": "dim-1",
    "qType": "dimension"
  },
  "qDim": {
    "qLabel": ">><< !#€%&/()=?",
    "qFieldDefs": [
      "({$<Type={'feature'}>} Size)"
    ]
  },
  "qMetaDef": {
    "title": ">><< !#€%&/()=?"
  }
}

This data is sent using enigma which escapes the characters.
I'll keep this issue open until it is fixed in enigma.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants