2016-11-27 1 views
-3

제가배열 형식 오류

{ "contractID"를 다음과 같이 배열을 가지고 27112016185818 "contractName": "DDF", "공급 업체 ID"5 "supplierName": "HH", "제품 ID"44 , "productName": "gg", "uom": "uu", "quantity": 6, "pricePerUOM": 6, "totalPrice": 36, "currency": "inr", "supplyByDate": "01112016" , "createdDate": "27112016", "loginuser": "구매자", "chain_id": "supplychainintegrity", "height": 244432, "num_txs": 1, "pendingWith": "", "block_hash": "hash ","block_data ":"데이터 ","data_hash ":"datahash ","block_time ":"시간 "}

나는 다음과 같은

[{"contractID":27112016185818,"contractName":"ddf","supplierID":5,"supplierName":"hh","productID":44,"productName":"gg","uom":"uu","quantity":6,"pricePerUOM":6,"totalPrice":36,"currency":"inr","supplyByDate":"01112016","createdDate":"27112016","loginuser":"buyer","chain_id":"supplychainintegrity","height":244432,"num_txs":1,"pendingWith":"","block_hash":"hash","block_data":"data","data_hash":"datahash","block_time":"time"}] 
로 변환 할

json stringification 용입니다.

jsonObj["row"]=currentArray; 
newArray=JSON.stringify(jsonObj); 

내 newArray 다음과 같이

{"row":{"contractID":27112016185818,"contractName":"ddf","supplierID":5,"supplierName":"hh","productID":44,"productName":"gg","uom":"uu","quantity":6,"pricePerUOM":6,"totalPrice":36,"currency":"inr","supplyByDate":"01112016","createdDate":"27112016","loginuser":"buyer","chain_id":"supplychainintegrity","height":244432,"num_txs":1,"pendingWith":"","block_hash":"hash","block_data":"data","data_hash":"datahash","block_time":"time"}} 

필요성을 다음과 같이

{ "행": [{ "contractID"27112016185818 "contractName": "DDF", "공급 업체 ID" 5, "supplierName": "hh", "productID": 44, "productName": "gg", "uom": "uu", "quantity": 6, "pricePerUOM": 6, "totalPrice" "구매자", "chain_id": "supplychainintegrity", "height": 244432, "num_txs": "inr", "supplyByDate": "0112016", "createdDate": "27112016" 1, "pendingWith": "", "block_hash": "hash", "block_data": "data", "data_hash": " datahash ","block_time ":"시간 "}]}

+0

차이가 읽을 수 있습니다 있도록 JSON 포맷을하시기 바랍니다. –

+0

@Tim Biegeleisen 나는 당신을 얻지 못했습니다. –

+0

[this] (http://jsonlint.com/) 사이트를 방문하십시오. JSON이 제대로 구조화되어 있는지 확인하는 강력한 도구이며 그렇지 않은 경우 불일치가 어디에 있는지 알려줍니다. – FDavidov

답변

1

당신은 간단하게이 작업을 수행 할 수

$scope.newarray = []; 
$scope.myObj = data.row; 
$scope.newarray.push($scope.myObj); 
console.log($scope.newarray); 

DEMO