json - 以字符串形式检索 JSON 数据
问题描述
我在我的网站中使用 Draft.js 作为编辑器。我可以将编辑器文本保存为数据库中的 json 格式。但我想将 json 数据保存为字符串/Html,但它是以 json 格式出现的。到目前为止,这是我为将值保存为 json 格式所做的工作:
<Editor
blockStyleFn={getBlockStyle}
customStyleMap={styleMap}
editorState={this.state.editorState}
handleKeyCommand={this.handleKeyCommand}
onChange={this.onChange}
placeholder="Describe the requirements and skills needed for the job"
ref="editor"
spellCheck={true}
/>
<h4>Editor content as HTML</h4>
<pre>{this.state.editorContentHtml}</pre>
这是在编辑器下显示 html 代码的功能:
this.onChange = editorState => {
this.setState({
editorState,
editorContentHtml: stateToHTML(editorState.getCurrentContent())
});
};
这是我的编辑器的快照
我想将 html 结果保存在数据库中,并将其显示为 html。如果有任何其他方法可以将数据检索为字符串格式,我们将不胜感激。
解决方案
推荐阅读
- node.js - 读取/设置套接字头信息 [Node.js]
- jhipster - 生成器-jhipster-blueprint “jhContext.setupClientOptions 不是函数”
- python - 我该如何安排这个函数,以便它返回一个包含所有这些列表的列表
- c++ - 两个相同的本地实例化模板可以跨越 DLL 边界吗?
- java - 触摸屏时应用程序崩溃
- cytoscape - 如何在 Cytoscape 圆形布局中删除背景图像?
- node.js - 在节点中的微服务之间共享 Mongoose Schema 是否很好
- android - FCM 令牌是否在操作系统更新时刷新?
- prometheus - prometheus 未启动(未加载 prometheus.yml 文件)
- ssl - Kafka Broker SSL - NoAuth 异常 - KeeperErrorCode NoAuth for /brokers/ids