eval
the lines below) containing the form data, not a string. Obviously, you can get its JSON representation from this object, but this is not the main task of the library.* This source code was highlighted with Source Code Highlighter .
- < input type = "text" name = "person.name.first" value = "John" />
- < input type = "text" name = "person.name.last" value = "Doe" />
* This source code was highlighted with Source Code Highlighter .
- {
- "person" :
- {
- "name" :
- {
- "first" : "John" ,
- "last" : "Doe"
- }
- }
- }
* This source code was highlighted with Source Code Highlighter .
- < label > < input type = "checkbox" name = "person.favFood []" value = "steak" checked = "checked" /> Steak </ label >
- < label > < input type = "checkbox" name = "person.favFood []" value = "pizza" /> Pizza </ label >
- < label > < input type = "checkbox" name = "person.favFood []" value = "chicken" checked = "checked" /> Chicken </ label >
* This source code was highlighted with Source Code Highlighter .
- {
- "person" :
- {
- "favFood" : [ "steak" , "chicken" ]
- }
- }
* This source code was highlighted with Source Code Highlighter .
- < dl >
- < dt > Give us your friends and friends </ dt >
- < dd >
- < label > Email < input type = "text" name = "person.friends [0] .email" value = "agent.smith@example.com" /> </ label >
- < label > Name < input type = "text" name = "person.friends [0] .name" value = "Smith Agent" /> </ label >
- </ dd >
- < dd >
- < label > Email < input type = "text" name = "person.friends [1] .email" value = "n3o@example.com" /> </ label >
- < label > Name < input type = "text" name = "person.friends [1] .name" value = "Thomas A. Anderson" /> </ label >
- </ dd >
- </ dt >
- </ dl >
* This source code was highlighted with Source Code Highlighter .
- {
- "person" :
- {
- "friends" : [
- { "email" : "agent.smith@example.com" , "name" : "Smith Agent" },
- { "email" : "n3o@example.com" , "name" : "Thomas A. Anderson" }
- ]
- }
- }
.serializeArray()
will make an example of an example with an array of objects:* This source code was highlighted with Source Code Highlighter .
- [
- { "person.friends [0] .email" : "agent.smith@example.com" },
- { "person.friends [0] .name" : "Smith Agent" },
- { "person.friends [1] .email" : "n3o@example.com" },
- { "person.friends [1] .name" : "Thomas A. Anderson" }
- ]
Source: https://habr.com/ru/post/104142/
All Articles