1

私はJSスクリプトをリバースエンジニアリングしているところです。どこかに言う:

var a = [{
    name: 'sample1',
     data: ["Otu1", "Otu2", "Otu3", "Otu4", "Otu5"],
     values: [5, 15, 250, 20, 23]
  },{
    name: 'sample2',
     data: ["Otu1", "Otu5", "Otu6", "Otu7"],
     values: [234, 29, 239, 5]
  }]

最初の質問:それはどのタイプのオブジェクトですか?JSONですか?それともJSONオブジェクトの配列ですか?

私はこれをこの形式で書く必要があります:

var b = {
    name: 'sample1',
     data: ["Otu1", "Otu2", "Otu3", "Otu4", "Otu5"],
     values: [5, 15, 250, 20, 23]
  }
var c = {
    name: 'sample2',
     data: ["Otu1", "Otu5", "Otu6", "Otu7"],
     values: [234, 29, 239, 5]
  }

var a = b + c 

手伝ってもらえますか?任意の洞察をいただければ幸いです。コミュニティありがとう!

4

2 に答える 2

1

"First question: What type of object is it? is it JSON? Or is it an array of JSON objects?"

It's an Array of JavaScript Objects. It could be serialized into JSON data, but currently you should just see it as JavaScript code. The notation is similar, but the resulting data is different.

(And actually in your case, for the notation to be JSON-like, you'd need to use double quotes. But even then, you're still creating JavaScript Objects)

"I need to write this in this form: "

For this, you could make an Array of JavaScript Objects like this:

var a = [b, c];
于 2012-12-10T01:50:29.030 に答える
0

You have an array of Objects here, remember JSON simply means JavaScript Object Notation

于 2012-12-10T01:51:05.397 に答える