I want to create single JSON object from three different JSON object eg
Three variable containing JSON value :
1. GTX_INNER_JOIN 2. GTX_LEFT_OUTER_JOIN 3. GTX_RIGHT_OUTER_JOIN
all of them have same (key,value) pair. I want single JSON containing value from all of them.
I have tried angularJS and tried Angular: Copy , Extend and Merge but i didnt get the result as i want .
var vGreenTXJSON = {};
angular.extend(vGreenTXJSON ,vGreenTxData.GTX_INNER_JOIN );
angular.extend(vGreenTXJSON ,vGreenTxData.GTX_LEFT_OUTER_JOIN );
angular.extend(vGreenTXJSON ,vGreenTxData.GTX_RIGHT_OUTER_JOIN );
I want single JSON eg
[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},...]
like this , but this is creating array of JSON like :
object :
[GTX_INNER_JOIN :[{},{},{},{},{},....],
GTX_LEFT_OUTER_JOIN:[{},{},{},{},{},....],
GTX_RIGHT_OUTER_JOIN:[{},{},{},{},{},....]]
it can be very helpful to specify the result you're expecting. you can do -
var vGreenTXJSON = {
innerJoin: vGreenTxData.GTX_INNER_JOIN,
leftOuterJoin: vGreenTxData.GTX_LEFT_OUTER_JOIN,
rightOuterJoin: vGreenTxData.GTX_RIGHT_OUTER_JOIN
};
If you directly copy all properties of vGreenTxData
to vGreenTXJSON
, you could use below.
angular.extend(vGreenTXJSON ,vGreenTxData);
If you want to specifically grab some of Props from vGreenTxData
object then it would be look like below.
angular.extend(vGreenTXJSON ,{
GTX_InnerJoin: vGreenTxData.GTX_INNER_JOIN,
GTX_OuterJoin: vGreenTxData.GTX_LEFT_OUTER_JOIN,
GTX_Right_OuterJoin: vGreenTxData.GTX_RIGHT_OUTER_JOIN
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.