javascript - 如何将数据转换为对象或如何将属性对象与值交换
问题描述
所以,基本上,我在网上找到了一个列表(RAW),上面有所有的股票市场公司名称和相应的股票代码。
我想将此数据转换为 JavaScript 对象以使用这些信息......像这样:
const companiesList =
{
Apple : "AAPL",
Amazon : "AMZN",
Microsoft : "MSFT",
IBM : "IBM",
Senseonics : "SENS",
PlugPower : "PLUG",
ExxonMobil : "XOM"
}
// The idea is to have the companie name has the propertie and the symbol as the value.
但是,如果我只是粘贴我找到的列表,我会得到这样的:
let companiesList =
{
A - Agilent Technologies,
AA - Alcoa,
AAC - Ares Acquisition,
AACE - Alexandria Agtech/Climate Innovation,
AACG - ATA Creativity Global,
AACO - Advancit Acquisition I,
AACP - Aeon Acquisition,
AACQ - Artius Acquisition,
AAIC - Arlington Asset Investment,
AAL - American Airlines,
AAMC - Altisource Asset Management,
AAME - Atlantic American,
AAN - The Aaron's Company,
AAOI - Applied Optoelectronics,
AAON - AAON, Inc.,
AAP - Advance Auto Parts,
AAPL - Apple,
...
}
所以,我想知道,因为这是一个大列表......如果有的话,我可以将此列表转换为第一个代码中显示的格式,而无需逐行更改它。
那将非常有用。谢谢
解决方案
推荐阅读
- python - PostgreSQL 服务器的 SQLAlchemy 过滤发生在哪里?(烧瓶-sqlalchemy)
- javascript - 我是否总是必须为每个表制作一个 Sequelize 模型文件?
- c# - 使用一种操作方法创建和更新记录
- python - NameError:名称“x_scalar”未定义
- android - 如何从适配器 kotlin 增加通知徽章的计数器
- angular - 将 bingsmaps 与 Angular 集成:未定义 Microsoft 错误
- c++ - Qt5 QListView 在水平行而不是垂直列表中设置项目
- html - 我可以改变 Flexbox 的收缩方式吗?
- php - 类表单控件不允许隐藏文本框隐藏在 html 中
- sapui5 - 根据条件操作表格行中的图标