I was wondering how can I create a JSON (JS) object and then clone it.

推荐答案

如何在javascript/jquery中创建JSON对象?

There is nothing like a JSON object. JSON stands for JavaScript Object Notation and is basically a string that encodes information similar to JavaScript's object literals.

You can however create such an encoding (which would result in a string) with JSON.stringify(object), see JSON in JavaScript. You could also create such a string manually, but it is very error prone and I don't recommend it.

How do I clone a JSON object in javascript/jquery?

As it is just a string:

var jsonString2 = jsonString;

我不能再使用javascript数组了.

JSON是exchange个数据的一种格式,它不是可以在应用程序中使用的数据 struct .


Maybe you want to read more about JSON, objects in JS and arrays in JS.

Json相关问答推荐

jq不会为空输入返回非零

无法从JSON解析ZonedDateTime,但可以使用格式化程序很好地解析

无法从MongoDB集合中检索正确的文档

规范化JSON数据

将不带正文的 CURL POST 转换为 RESTRequest Delphi 代码 / 为 Dropbox API /get_current_account 端点编写 Delphi 代码

如何将具有相同 struct 的多个JSON文件中的对象数组合并成一个数组?

将环境变量值从 yaml 传递到 json

将 JSON 字符串解析为 Kotlin Android 中的对象列表(MOSHI?)

如何在linux中用jq过滤json数组?

Powershell 无法从名为 count 的键中获取价值

杰克逊 2.0 和 Spring 3.1

JSON.NET 中特定对象的自定义转换

如何使用 Newtonsoft.Json 反序列化 JSON 数组

如何从 JSON 对象中获取日期

如何在 Eclipse 中安装和使用 JSON 编辑器?

规范化 JSON 文件

了解 JSON Schema 草稿版本 4 中的additionalProperties关键字

如何向从文件中检索的 JSON 数据添加键值?

java.lang.BootstrapMethodError:调用站点#4 bootstrap 方法的异常,初始化 retrofit 时

使用新的 Net Core 3.0 Json 时忽略属性