MCPcopy Create free account
hub / github.com/gawel/pyquery / serialize_array

Method serialize_array

pyquery/pyquery.py:1519–1533  ·  view source on GitHub ↗

Serialize form elements as an array of dictionaries, whose structure mirrors that produced by the jQuery API. Notably, it does not handle the deprecated `keygen` form element. >>> d = PyQuery(' ') >>> d.serialize_a

(self)

Source from the content-addressed store, hash-verified

1517
1518 @with_camel_case_alias
1519 def serialize_array(self):
1520 """Serialize form elements as an array of dictionaries, whose structure
1521 mirrors that produced by the jQuery API. Notably, it does not handle
1522 the deprecated `keygen` form element.
1523
1524 >>> d = PyQuery('<form><input name="order" value="spam"></form>')
1525 >>> d.serialize_array() == [{'name': 'order', 'value': 'spam'}]
1526 True
1527 >>> d.serializeArray() == [{'name': 'order', 'value': 'spam'}]
1528 True
1529 """
1530 return list(map(
1531 lambda p: {'name': p[0], 'value': p[1]},
1532 self.serialize_pairs()
1533 ))
1534
1535 def serialize(self):
1536 """Serialize form elements as a URL-encoded string.

Callers 1

test_serialize_arrayMethod · 0.80

Calls 1

serialize_pairsMethod · 0.95

Tested by 1

test_serialize_arrayMethod · 0.64