How to structure this data set?

I am dealing with a set of fields, where each field has a display name and an internal name. For example: - Due Date => DueDate - Created By => Author - Title => Title - Author => Author0 Note that a display name can be identical to its internal name, or identical to another field's internal name (cf. above examples). The total number of fields is between 50 and 100. I need the following methods: - get internal name from display name - get display name from internal name - check if a display name exists - check if an internal name exists How should I structure the data to address these needs? The most straightforward seems to be to build two objects: {"Due Date":"DueDate","Created By":"Author",...} {"DueDate":"Due Date","Author":"Created By",...} However I don't like the redundancy, and I am wondering if there's a better way. Other options I am considering: Array of objects: [{display:"Due Date",internal:"DueDate"},...] Simple array: ["Due Date","DueDate","Created By","Author",...]
This question is more appropriate for programmers.stackexchange.com, or maybe Code Review. Stack Overflow is for specific questions about coding with definite answers; Programmers is for discussions of design concepts and best practices. Please read this meta post for more information.

以上就是How to structure this data set?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏