Skip to content

Commit

Permalink
fixed issue with skipEmpty and nested input value #25
Browse files Browse the repository at this point in the history
  • Loading branch information
brainfoolong committed Feb 9, 2022
1 parent adacd63 commit a937648
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 18 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
### 2.1.2 - 2022-02-09

* fixed issue with skipEmpty and nested input value #25

### 2.1.1 - 06.December 2021

* accept a `$` instance also as html element in `toJson/fromJson`, which is used by many libraries that memic jquery behaviour - previously only explicitly `jQuery` was supported
* accept a `$` instance also as html element in `toJson/fromJson`, which is used by many libraries that memic jquery
behaviour - previously only explicitly `jQuery` was supported


* ### 2.1.0 - 24.October 2021
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ You can edit this defaults globally by modifying `FormDataJson.defaultOptionsToJ
'flatList': false,

/**
* If true, than this does skip empty fields from the output
* If true, then this does skip empty fields from the output
* Empty is considered to be:
* An empty array (for multiple selects/checkboxes)
* An empty input field (length = 0)
Expand Down
9 changes: 5 additions & 4 deletions dist/form-data-json.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
// form-data-json-convert | version: 2.1.1 | url: https://github.com/brainfoolong/form-data-json
// form-data-json-convert | version: 2.1.2 | url: https://github.com/brainfoolong/form-data-json

/**
* Form Data Json Converter
Expand Down Expand Up @@ -209,6 +209,7 @@ var FormDataJson = /*#__PURE__*/function () {
* Recursively remove empty keys
* @param {Object} object
* @param {number} depth
* @return {Object|Array}
*/


Expand All @@ -233,7 +234,7 @@ var FormDataJson = /*#__PURE__*/function () {
}

if (isArray) {
newObject.push(object[key]);
newObject.push(options.flatList && !depth ? [object[key][0], value] : value);
} else {
newObject[key] = value;
}
Expand Down Expand Up @@ -690,7 +691,7 @@ var FormDataJson = /*#__PURE__*/function () {
;

FormDataJson.isArray = function isArray(arg) {
return typeof arg === 'object' && Object.prototype.toString.call(arg) === '[object Array]';
return Array.isArray(arg);
}
/**
* Get html element out of given parameter
Expand Down Expand Up @@ -772,7 +773,7 @@ FormDataJson.defaultOptionsToJson = {
'flatList': false,

/**
* If true, than this does skip empty fields from the output
* If true, then this does skip empty fields from the output
* Empty is considered to be:
* An empty array (for multiple selects/checkboxes)
* An empty input field (length = 0)
Expand Down
4 changes: 2 additions & 2 deletions dist/form-data-json.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions docs/scripts/form-data-json.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
// form-data-json-convert | version: 2.1.1 | url: https://github.com/brainfoolong/form-data-json
// form-data-json-convert | version: 2.1.2 | url: https://github.com/brainfoolong/form-data-json

/**
* Form Data Json Converter
Expand Down Expand Up @@ -209,6 +209,7 @@ var FormDataJson = /*#__PURE__*/function () {
* Recursively remove empty keys
* @param {Object} object
* @param {number} depth
* @return {Object|Array}
*/


Expand All @@ -233,7 +234,7 @@ var FormDataJson = /*#__PURE__*/function () {
}

if (isArray) {
newObject.push(object[key]);
newObject.push(options.flatList && !depth ? [object[key][0], value] : value);
} else {
newObject[key] = value;
}
Expand Down Expand Up @@ -690,7 +691,7 @@ var FormDataJson = /*#__PURE__*/function () {
;

FormDataJson.isArray = function isArray(arg) {
return typeof arg === 'object' && Object.prototype.toString.call(arg) === '[object Array]';
return Array.isArray(arg);
}
/**
* Get html element out of given parameter
Expand Down Expand Up @@ -772,7 +773,7 @@ FormDataJson.defaultOptionsToJson = {
'flatList': false,

/**
* If true, than this does skip empty fields from the output
* If true, then this does skip empty fields from the output
* Empty is considered to be:
* An empty array (for multiple selects/checkboxes)
* An empty input field (length = 0)
Expand Down
Loading

0 comments on commit a937648

Please sign in to comment.