I need this json data in the below format using JSONATASerializing to JSON in jQueryHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?Why does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?Jackson with JSON: Unrecognized field, not marked as ignorableHow do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?The “right” JSON date format
How can electricity be positive when electrons are negative?
Why is Western European music harmonically driven?
How do we create our own symbolisms?
How should Thaumaturgy's "three times as loud as normal" be interpreted?
Compiler optimization of bitwise not operation
What can we do about our 9-month-old putting fingers down his throat?
How strong is aircraft-grade spruce?
Project Euler problem #112
Is this ram compatible with iMac 27"?
What is the delta-v required to get a mass in Earth orbit into the sun using a SINGLE transfer?
Is it right to use the ideas of non-winning designers in a design contest?
Protecting programs on external drives with the same priviledges as in Program Files
Supervisor wants me to support a diploma-thesis SW tool after I graduated
How to plot two curves with the same area under?
Friend is very nitpicky about side comments I don't intend to be taken too seriously
Why are UK MPs allowed to abstain (but it counts as a no)?
Dragons and gems
Do you need to burn fuel between gravity assists?
How do draw effects during the discard phase work?
Is there some sort of French saying for "a person's signature move"?
Short story: Interstellar inspector senses "off" nature of planet hiding aggressive culture
What is the highest velocity a spacecraft has left Earth?
Word for something that used to be popular but not anymore
What's the biggest difference between these two photos?
I need this json data in the below format using JSONATA
Serializing to JSON in jQueryHow do I format a Microsoft JSON date?Can comments be used in JSON?How can I pretty-print JSON in a shell script?What is the correct JSON content type?Why does Google prepend while(1); to their JSON responses?Why can't Python parse this JSON data?Jackson with JSON: Unrecognized field, not marked as ignorableHow do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?The “right” JSON date format
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Below json is my input.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
Using JSONATA i need to format the above JSON to below format.
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
I tried payload.[$keys()]
but this will yield only keys in array format not whole object in array format.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
to
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
json jsonata
add a comment |
Below json is my input.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
Using JSONATA i need to format the above JSON to below format.
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
I tried payload.[$keys()]
but this will yield only keys in array format not whole object in array format.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
to
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
json jsonata
add a comment |
Below json is my input.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
Using JSONATA i need to format the above JSON to below format.
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
I tried payload.[$keys()]
but this will yield only keys in array format not whole object in array format.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
to
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
json jsonata
Below json is my input.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
Using JSONATA i need to format the above JSON to below format.
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
I tried payload.[$keys()]
but this will yield only keys in array format not whole object in array format.
"payload":
"KA01B3432": "KA01B3432",
"KA02A3123": "KA02A3123"
to
[
"KA01B3432": "KA01B3432"
,
"KA02A3123": "KA02A3123"
]
json jsonata
json jsonata
edited Mar 28 at 9:14
Mebin Joe
1,2161 gold badge11 silver badges20 bronze badges
1,2161 gold badge11 silver badges20 bronze badges
asked Mar 28 at 6:26
sachin chaurasiasachin chaurasia
31 bronze badge
31 bronze badge
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$spread(payload)
does what you need.
See http://try.jsonata.org/S1COdDqO4
Thank you so much for your solution :)
– sachin chaurasia
Apr 25 at 6:50
add a comment |
What about the following code :
var json = "payload": "KA01B3432": "KA01B34321", "KA02A3123": "KA02A31231" ;
var array = [];
keys = Object.keys(json.payload);
values = Object.values(json.payload);
for (var i = 0; i < keys.length; i++)
var item = ;
item[keys[i]] = values[i];
array.push(item);
console.log(array);
I used the same code but still it is not providing the expected result.
– sachin chaurasia
Mar 28 at 8:20
[ key: 'KA01B3432', value: 'KA01B34321' , key: 'KA02A3123', value: 'KA02A31231' ] This is what I recieved by running your code, but in the expected result there is no "Key" and "Value" words.
– sachin chaurasia
Mar 28 at 8:22
use this please item[keys[i]] = values[i]; i'm going to update the answer and this will provide exactly what you need
– Mahmoud-Abdelslam
Mar 28 at 8:25
Now it is working as expected, Thank you :)
– sachin chaurasia
Apr 25 at 6:53
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391350%2fi-need-this-json-data-in-the-below-format-using-jsonata%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$spread(payload)
does what you need.
See http://try.jsonata.org/S1COdDqO4
Thank you so much for your solution :)
– sachin chaurasia
Apr 25 at 6:50
add a comment |
$spread(payload)
does what you need.
See http://try.jsonata.org/S1COdDqO4
Thank you so much for your solution :)
– sachin chaurasia
Apr 25 at 6:50
add a comment |
$spread(payload)
does what you need.
See http://try.jsonata.org/S1COdDqO4
$spread(payload)
does what you need.
See http://try.jsonata.org/S1COdDqO4
answered Mar 28 at 15:31
Andrew ColemanAndrew Coleman
3811 silver badge4 bronze badges
3811 silver badge4 bronze badges
Thank you so much for your solution :)
– sachin chaurasia
Apr 25 at 6:50
add a comment |
Thank you so much for your solution :)
– sachin chaurasia
Apr 25 at 6:50
Thank you so much for your solution :)
– sachin chaurasia
Apr 25 at 6:50
Thank you so much for your solution :)
– sachin chaurasia
Apr 25 at 6:50
add a comment |
What about the following code :
var json = "payload": "KA01B3432": "KA01B34321", "KA02A3123": "KA02A31231" ;
var array = [];
keys = Object.keys(json.payload);
values = Object.values(json.payload);
for (var i = 0; i < keys.length; i++)
var item = ;
item[keys[i]] = values[i];
array.push(item);
console.log(array);
I used the same code but still it is not providing the expected result.
– sachin chaurasia
Mar 28 at 8:20
[ key: 'KA01B3432', value: 'KA01B34321' , key: 'KA02A3123', value: 'KA02A31231' ] This is what I recieved by running your code, but in the expected result there is no "Key" and "Value" words.
– sachin chaurasia
Mar 28 at 8:22
use this please item[keys[i]] = values[i]; i'm going to update the answer and this will provide exactly what you need
– Mahmoud-Abdelslam
Mar 28 at 8:25
Now it is working as expected, Thank you :)
– sachin chaurasia
Apr 25 at 6:53
add a comment |
What about the following code :
var json = "payload": "KA01B3432": "KA01B34321", "KA02A3123": "KA02A31231" ;
var array = [];
keys = Object.keys(json.payload);
values = Object.values(json.payload);
for (var i = 0; i < keys.length; i++)
var item = ;
item[keys[i]] = values[i];
array.push(item);
console.log(array);
I used the same code but still it is not providing the expected result.
– sachin chaurasia
Mar 28 at 8:20
[ key: 'KA01B3432', value: 'KA01B34321' , key: 'KA02A3123', value: 'KA02A31231' ] This is what I recieved by running your code, but in the expected result there is no "Key" and "Value" words.
– sachin chaurasia
Mar 28 at 8:22
use this please item[keys[i]] = values[i]; i'm going to update the answer and this will provide exactly what you need
– Mahmoud-Abdelslam
Mar 28 at 8:25
Now it is working as expected, Thank you :)
– sachin chaurasia
Apr 25 at 6:53
add a comment |
What about the following code :
var json = "payload": "KA01B3432": "KA01B34321", "KA02A3123": "KA02A31231" ;
var array = [];
keys = Object.keys(json.payload);
values = Object.values(json.payload);
for (var i = 0; i < keys.length; i++)
var item = ;
item[keys[i]] = values[i];
array.push(item);
console.log(array);
What about the following code :
var json = "payload": "KA01B3432": "KA01B34321", "KA02A3123": "KA02A31231" ;
var array = [];
keys = Object.keys(json.payload);
values = Object.values(json.payload);
for (var i = 0; i < keys.length; i++)
var item = ;
item[keys[i]] = values[i];
array.push(item);
console.log(array);
edited Mar 28 at 8:26
answered Mar 28 at 7:18
Mahmoud-AbdelslamMahmoud-Abdelslam
1591 silver badge7 bronze badges
1591 silver badge7 bronze badges
I used the same code but still it is not providing the expected result.
– sachin chaurasia
Mar 28 at 8:20
[ key: 'KA01B3432', value: 'KA01B34321' , key: 'KA02A3123', value: 'KA02A31231' ] This is what I recieved by running your code, but in the expected result there is no "Key" and "Value" words.
– sachin chaurasia
Mar 28 at 8:22
use this please item[keys[i]] = values[i]; i'm going to update the answer and this will provide exactly what you need
– Mahmoud-Abdelslam
Mar 28 at 8:25
Now it is working as expected, Thank you :)
– sachin chaurasia
Apr 25 at 6:53
add a comment |
I used the same code but still it is not providing the expected result.
– sachin chaurasia
Mar 28 at 8:20
[ key: 'KA01B3432', value: 'KA01B34321' , key: 'KA02A3123', value: 'KA02A31231' ] This is what I recieved by running your code, but in the expected result there is no "Key" and "Value" words.
– sachin chaurasia
Mar 28 at 8:22
use this please item[keys[i]] = values[i]; i'm going to update the answer and this will provide exactly what you need
– Mahmoud-Abdelslam
Mar 28 at 8:25
Now it is working as expected, Thank you :)
– sachin chaurasia
Apr 25 at 6:53
I used the same code but still it is not providing the expected result.
– sachin chaurasia
Mar 28 at 8:20
I used the same code but still it is not providing the expected result.
– sachin chaurasia
Mar 28 at 8:20
[ key: 'KA01B3432', value: 'KA01B34321' , key: 'KA02A3123', value: 'KA02A31231' ] This is what I recieved by running your code, but in the expected result there is no "Key" and "Value" words.
– sachin chaurasia
Mar 28 at 8:22
[ key: 'KA01B3432', value: 'KA01B34321' , key: 'KA02A3123', value: 'KA02A31231' ] This is what I recieved by running your code, but in the expected result there is no "Key" and "Value" words.
– sachin chaurasia
Mar 28 at 8:22
use this please item[keys[i]] = values[i]; i'm going to update the answer and this will provide exactly what you need
– Mahmoud-Abdelslam
Mar 28 at 8:25
use this please item[keys[i]] = values[i]; i'm going to update the answer and this will provide exactly what you need
– Mahmoud-Abdelslam
Mar 28 at 8:25
Now it is working as expected, Thank you :)
– sachin chaurasia
Apr 25 at 6:53
Now it is working as expected, Thank you :)
– sachin chaurasia
Apr 25 at 6:53
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391350%2fi-need-this-json-data-in-the-below-format-using-jsonata%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown