Rename json keys



    majid ghasemi

    The code converts the string "DataList[2]" to a JSON object and replaces the "errMessages" field with "errors". The resulting JSON object is then parsed to produce the following new JSON object:

    { "errors": "There was an error processing the data.

    Library: react

    var s = JSON.stringify(DataList[2]);
      var t = s.replace(/"errMessages"/g, '"errors"');
      var newJson = JSON.parse(t);
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.