Jasmine
2.0.0
finished in 0.01s
raise exceptions
Ran 0 of 94 specs - run all
0 specs, 0 failures
$.serializeJSON
accepts a jQuery or Zepto object with a form
accepts a jQuery object with inputs
accepts a jQuery object with forms and inputs
with simple one-level attributes
serializes into plain attributes
with nested object attributes
serializes into nested object attributes
with empty brackets (arrays)
pushes elements into an array
with attribute names that are integers
still creates objects with keys that are strings
with a select multiple
serializes all the selected elements
ignores the field if nothing is selected
can be set to empty string using a hidden field
with complext array of objects
serializes into array of objects
with existing properties
overrides to keep the last property value
unchecked checkboxes
are ignored by default (same as regural HTML forms and the jQuery.serializeArray function)
are ignored also in arrays
could use a hidden field and a custom parser to force an empty array in an array of unchecked checkboxes
could use a hidden field with type :array to force an empty array in an array of unchecked checkboxes
can be combined with hidden fields to set the false value
use the checkboxUncheckedValue option if defined
use the HTML5 data-unchecked-value if defined
should be ignored if they have no name
value types
:number
parses numbers
parses non numbers to NaN
:boolean
parses anything that looks truthy to true
parses anything that looks falsy to false
:null
parses anything that looks falsy to null
keeps anything that looks truthy as string
:string
keeps everything as string
is useful to override other parse options
:array
parses arrays with JSON.parse
raises an error if the array can not be parsed
:object
parses objects with JSON.parse
raises an error if the obejct can not be parsed
:skip
removes the field from the parsed result
raises an error if the obejct can not be parsed
:auto
parses Strings, Booleans and Nulls if they look like they could be one of them (same as parseAll option)
does not auto-recognize arrays or objects
invalid types
raises an error if the type is not known
form with multiple types
parses every type as expected
data-value-type attribute
should set type if field name do not contain :type definition
also works for matched inputs (not just forms) if they have the data-value-type attribute
options
defaults (defaultOptions)
returns strings
validateOptions
should raise an error if the option is not one of the valid options
parseNumbers
returns numbers for the numeric string values
parseBooleans
returns booleans for the 'true'/'false' values
parseNulls
returns null for the 'null' values
parseAll
parses all possible values
parseWithFunction custom parser
uses the passed in function to parse values
can be combined with other parse options
checkboxUncheckedValue
uses that value for unchecked checkboxes
is overriden by data-unchecked-value attribute
is parsed by parse options
is parsed by custom parseWithFunction
works on multiple forms and inputs
works on a list of checkboxes
works on a nested list of checkboxes
does not serialize disabled checkboxes
useIntKeysAsArrayIndex
uses int keys as array indexes instead of object properties
doesnt get confused by attribute names that are similar to integers, but not valid array indexes
customTypes
serializes value according to custom function without disturbing default types
overrides defaultTypes
overrides defaultTypes even if they are re-defined
with modified defaults
uses those options by default
merges options with defaults
can be overriden with different options
parseAll will override all other parse options
allows to set default for checkboxUncheckedValue
$.serializeJSON.extractTypeAndNameWithNoType
returns an object with type and nameWithNoType properties form the name with :type colon notation
$.serializeJSON.splitInputNameIntoKeysArray
accepts a simple name
accepts a name wrapped in brackets
accepts names separated by brackets
accepts empty brakets as empty strings
accepts nested brackets
$.serializeJSON.isValidArrayIndex
accepts positive integers
rejects negative integers
rejects strings, objects and arrays
$.serializeJSON.deepSet
simple attr ['foo']
simple attr ['foo'] twice should set the last value
nested attr ['inn', 'foo']
nested attr ['inn', 'foo'] twice should set the last value
multiple assign attr ['foo'] and ['inn', 'foo']
very nested attr ['inn', 'inn', 'inn', 'foo']
array push with empty index, if repeat same object element key then it creates a new element
array push with empty index and empty value, also creates a new element
array assign with empty index should push the element
nested array assign with empty index should push the element
nested arrays with empty indexes should push the elements to the most deep array
with useIntKeysAsArrayIndex option
simple array ['0']
nested simple array ['arr', '0']
nested simple array multiple values
nested arrays with indexes should create a matrix
nested object as array element ['arr', '0', 'foo']
array of objects
nested arrays mixing empty indexes with numeric indexes should push when using empty but assign when using numeric
should set all different nested values