Need to format JSON output in order to be compatible with my backend serviceHow can I “pretty” format my JSON output in Ruby on Rails?How do I format a Microsoft JSON date?How do I return clean JSON from a WCF Service?Javascript: How to generate formatted easy-to-read JSON straight from an object?Posting a File and Associated Data to a RESTful WebService preferably as JSONHow to decide when to use Node.js?How can I add new array elements at the beginning of an array in Javascript?The “right” JSON date formatStandard JSON API response format?Representing null in JSON

What's the point of deactivating Num Lock on login screens?

Does detail obscure or enhance action?

How is it possible to have an ability score that is less than 3?

Watching something be written to a file live with tail

Could an aircraft fly or hover using only jets of compressed air?

Important Resources for Dark Age Civilizations?

High voltage LED indicator 40-1000 VDC without additional power supply

Add text to same line using sed

LWC SFDX source push error TypeError: LWC1009: decl.moveTo is not a function

Why is Minecraft giving an OpenGL error?

Is it inappropriate for a student to attend their mentor's dissertation defense?

How does one intimidate enemies without having the capacity for violence?

Java Casting: Java 11 throws LambdaConversionException while 1.8 does not

Is it possible to do 50 km distance without any previous training?

If human space travel is limited by the G force vulnerability, is there a way to counter G forces?

strTok function (thread safe, supports empty tokens, doesn't change string)

What's that red-plus icon near a text?

How much RAM could one put in a typical 80386 setup?

Do infinite dimensional systems make sense?

Why can't I see bouncing of a switch on an oscilloscope?

What's the output of a record needle playing an out-of-speed record

Why does Kotter return in Welcome Back Kotter?

Alternative to sending password over mail?

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?



Need to format JSON output in order to be compatible with my backend service


How can I “pretty” format my JSON output in Ruby on Rails?How do I format a Microsoft JSON date?How do I return clean JSON from a WCF Service?Javascript: How to generate formatted easy-to-read JSON straight from an object?Posting a File and Associated Data to a RESTful WebService preferably as JSONHow to decide when to use Node.js?How can I add new array elements at the beginning of an array in Javascript?The “right” JSON date formatStandard JSON API response format?Representing null in JSON






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-4















I have a JSON output from a form like this




"testRefs":
"testCd": null,
"testIndicator": null,
"testInd": null,
"testiolInd": null
,
"testList":
"testname": null,
"testcode": null
,
"testCd": "someStrinf",
"testNm": "someString"



I need to format the form output to




"testRefs": [

"testCd": null,
"testIndicator": null,
"testInd": null,
"testiolInd": null
],

"testList": [

"testname": null,
"testcode": null

],
"testCd": "someStrinf",
"testNm": "someString"

]



to be compatible with backend service



How do i add array signs










share|improve this question






























    -4















    I have a JSON output from a form like this




    "testRefs":
    "testCd": null,
    "testIndicator": null,
    "testInd": null,
    "testiolInd": null
    ,
    "testList":
    "testname": null,
    "testcode": null
    ,
    "testCd": "someStrinf",
    "testNm": "someString"



    I need to format the form output to




    "testRefs": [

    "testCd": null,
    "testIndicator": null,
    "testInd": null,
    "testiolInd": null
    ],

    "testList": [

    "testname": null,
    "testcode": null

    ],
    "testCd": "someStrinf",
    "testNm": "someString"

    ]



    to be compatible with backend service



    How do i add array signs










    share|improve this question


























      -4












      -4








      -4








      I have a JSON output from a form like this




      "testRefs":
      "testCd": null,
      "testIndicator": null,
      "testInd": null,
      "testiolInd": null
      ,
      "testList":
      "testname": null,
      "testcode": null
      ,
      "testCd": "someStrinf",
      "testNm": "someString"



      I need to format the form output to




      "testRefs": [

      "testCd": null,
      "testIndicator": null,
      "testInd": null,
      "testiolInd": null
      ],

      "testList": [

      "testname": null,
      "testcode": null

      ],
      "testCd": "someStrinf",
      "testNm": "someString"

      ]



      to be compatible with backend service



      How do i add array signs










      share|improve this question
















      I have a JSON output from a form like this




      "testRefs":
      "testCd": null,
      "testIndicator": null,
      "testInd": null,
      "testiolInd": null
      ,
      "testList":
      "testname": null,
      "testcode": null
      ,
      "testCd": "someStrinf",
      "testNm": "someString"



      I need to format the form output to




      "testRefs": [

      "testCd": null,
      "testIndicator": null,
      "testInd": null,
      "testiolInd": null
      ],

      "testList": [

      "testname": null,
      "testcode": null

      ],
      "testCd": "someStrinf",
      "testNm": "someString"

      ]



      to be compatible with backend service



      How do i add array signs







      javascript json






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 5:51









      georgeawg

      34.5k115370




      34.5k115370










      asked Mar 8 at 2:20









      Suganthan SelvarajSuganthan Selvaraj

      11




      11






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can use for..in and check the length of keys at obj[key] if it's greater than 1 just add it in an array else keep it unchanged.






          let obj = "testRefs": "testCd": null,"testIndicator": null,"testInd": null,"testiolInd": null,"testList": "testname": null,"testcode": null,"testCd": null,"testNm": null

          for(let key in obj)
          if(Object.keys(obj[key]

          console.log(obj)








          share|improve this answer























          • If a string is passed at "testCd" / "testNm" they get added as array too. I've edited my question as per this problem

            – Suganthan Selvaraj
            Mar 8 at 6:18












          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/3.0/"u003ecc by-sa 3.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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55055811%2fneed-to-format-json-output-in-order-to-be-compatible-with-my-backend-service%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can use for..in and check the length of keys at obj[key] if it's greater than 1 just add it in an array else keep it unchanged.






          let obj = "testRefs": "testCd": null,"testIndicator": null,"testInd": null,"testiolInd": null,"testList": "testname": null,"testcode": null,"testCd": null,"testNm": null

          for(let key in obj)
          if(Object.keys(obj[key]

          console.log(obj)








          share|improve this answer























          • If a string is passed at "testCd" / "testNm" they get added as array too. I've edited my question as per this problem

            – Suganthan Selvaraj
            Mar 8 at 6:18
















          0














          You can use for..in and check the length of keys at obj[key] if it's greater than 1 just add it in an array else keep it unchanged.






          let obj = "testRefs": "testCd": null,"testIndicator": null,"testInd": null,"testiolInd": null,"testList": "testname": null,"testcode": null,"testCd": null,"testNm": null

          for(let key in obj)
          if(Object.keys(obj[key]

          console.log(obj)








          share|improve this answer























          • If a string is passed at "testCd" / "testNm" they get added as array too. I've edited my question as per this problem

            – Suganthan Selvaraj
            Mar 8 at 6:18














          0












          0








          0







          You can use for..in and check the length of keys at obj[key] if it's greater than 1 just add it in an array else keep it unchanged.






          let obj = "testRefs": "testCd": null,"testIndicator": null,"testInd": null,"testiolInd": null,"testList": "testname": null,"testcode": null,"testCd": null,"testNm": null

          for(let key in obj)
          if(Object.keys(obj[key]

          console.log(obj)








          share|improve this answer













          You can use for..in and check the length of keys at obj[key] if it's greater than 1 just add it in an array else keep it unchanged.






          let obj = "testRefs": "testCd": null,"testIndicator": null,"testInd": null,"testiolInd": null,"testList": "testname": null,"testcode": null,"testCd": null,"testNm": null

          for(let key in obj)
          if(Object.keys(obj[key]

          console.log(obj)








          let obj = "testRefs": "testCd": null,"testIndicator": null,"testInd": null,"testiolInd": null,"testList": "testname": null,"testcode": null,"testCd": null,"testNm": null

          for(let key in obj)
          if(Object.keys(obj[key]

          console.log(obj)





          let obj = "testRefs": "testCd": null,"testIndicator": null,"testInd": null,"testiolInd": null,"testList": "testname": null,"testcode": null,"testCd": null,"testNm": null

          for(let key in obj)
          if(Object.keys(obj[key]

          console.log(obj)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 2:31









          Code ManiacCode Maniac

          11.4k2833




          11.4k2833












          • If a string is passed at "testCd" / "testNm" they get added as array too. I've edited my question as per this problem

            – Suganthan Selvaraj
            Mar 8 at 6:18


















          • If a string is passed at "testCd" / "testNm" they get added as array too. I've edited my question as per this problem

            – Suganthan Selvaraj
            Mar 8 at 6:18

















          If a string is passed at "testCd" / "testNm" they get added as array too. I've edited my question as per this problem

          – Suganthan Selvaraj
          Mar 8 at 6:18






          If a string is passed at "testCd" / "testNm" they get added as array too. I've edited my question as per this problem

          – Suganthan Selvaraj
          Mar 8 at 6:18




















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55055811%2fneed-to-format-json-output-in-order-to-be-compatible-with-my-backend-service%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved