{"record":{"id":"16bf510c239fa202","repo":"dotnet/AspNetCore.Docs","slug":"ko-mapping-updatefromjson-use-ko-mapping-fromjson","errorCode":null,"errorMessage":"ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!","messagePattern":"ko\\.mapping\\.updateFromJSON, use ko\\.mapping\\.fromJSON instead\\. Please note that the order of parameters is different!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"aspnetcore/mvc/controllers/testing/samples/2.x/TestingControllersSample/src/TestingControllersSample/wwwroot/js/knockout.mapping.js","lineNumber":148,"sourceCode":"\t\t\treturn result;\n\t\t} catch(e) {\n\t\t\tmappingNesting = 0;\n\t\t\tthrow e;\n\t\t}\n\t};\n\n\texports.fromJSON = function (jsonString /*, options, target*/ ) {\n\t\tvar parsed = ko.utils.parseJson(jsonString);\n\t\targuments[0] = parsed;\n\t\treturn exports.fromJS.apply(this, arguments);\n\t};\n\n\texports.updateFromJS = function (viewModel) {\n\t\tthrow new Error(\"ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!\");\n\t};\n\n\texports.updateFromJSON = function (viewModel) {\n\t\tthrow new Error(\"ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!\");\n\t};\n\n\texports.toJS = function (rootObject, options) {\n\t\tif (!defaultOptions) exports.resetDefaultOptions();\n\n\t\tif (arguments.length == 0) throw new Error(\"When calling ko.mapping.toJS, pass the object you want to convert.\");\n\t\tif (exports.getType(defaultOptions.ignore) !== \"array\") throw new Error(\"ko.mapping.defaultOptions().ignore should be an array.\");\n\t\tif (exports.getType(defaultOptions.include) !== \"array\") throw new Error(\"ko.mapping.defaultOptions().include should be an array.\");\n\t\tif (exports.getType(defaultOptions.copy) !== \"array\") throw new Error(\"ko.mapping.defaultOptions().copy should be an array.\");\n\n\t\t// Merge in the options used in fromJS\n\t\toptions = fillOptions(options, rootObject[mappingProperty]);\n\n\t\t// We just unwrap everything at every level in the object graph\n\t\treturn exports.visitModel(rootObject, function (x) {\n\t\t\treturn ko.utils.unwrapObservable(x)\n\t\t}, options);\n\t};","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/dotnet/AspNetCore.Docs/blob/c67a80103a1a74db20784debd919c7fdda96c510/aspnetcore/mvc/controllers/testing/samples/2.x/TestingControllersSample/src/TestingControllersSample/wwwroot/js/knockout.mapping.js#L130-L166","documentation":"knockout.mapping removed updateFromJSON the same way it removed updateFromJS. The stub always throws and points to fromJSON. Because fromJSON parses a JSON string internally and forwards to fromJS, the argument order is again different (jsonString first, then target). The message is an intentional deprecation breadcrumb.","triggerScenarios":"Calling ko.mapping.updateFromJSON(viewModel, jsonString) carried over from an old knockout.mapping version.","commonSituations":"Plugin upgrade; legacy code; old Stack Overflow answers.","solutions":["Replace ko.mapping.updateFromJSON(viewModel, jsonString) with ko.mapping.fromJSON(jsonString, viewModel).","Migrate any sibling updateFromJS calls at the same time for consistency."],"exampleFix":"// before\nko.mapping.updateFromJSON(viewModel, jsonString);\n// after\nko.mapping.fromJSON(jsonString, viewModel);","handlingStrategy":"validation","validationCode":"// Compat shim for the removed updateFromJSON.\nfunction updateFromJSONCompat(viewModel, jsonString) {\n  if (typeof jsonString !== 'string') {\n    throw new TypeError('updateFromJSON requires a JSON string');\n  }\n  return ko.mapping.fromJSON(jsonString, viewModel); // order swapped\n}","typeGuard":"function isJsonString(x) { return typeof x === 'string' && x.trim().charAt(0) === '{' || x.trim().charAt(0) === '['; }","tryCatchPattern":"try {\n  ko.mapping.updateFromJSON(viewModel, jsonString);\n} catch (e) {\n  if (/use ko.mapping.fromJSON instead/.test(e.message)) {\n    console.error('Deprecated: use ko.mapping.fromJSON(jsonString, viewModel)');\n    ko.mapping.fromJSON(jsonString, viewModel);\n  } else { throw e; }\n}","preventionTips":["Remove all updateFromJSON usages when upgrading knockout.mapping.","Argument order is swapped: JSON string first, then target.","Add an ESLint/custom lint rule banning updateFromJSON/updateFromJS."],"tags":["knockout","knockout-mapping","deprecated","migration","breaking-change"],"backgroundTag":null,"analyzedSha":"c67a80103a1a74db20784debd919c7fdda96c510","analyzedAt":"2026-08-13T17:46:11.763Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}