mirror of
				https://github.com/taigrr/yq
				synced 2025-01-18 04:53:17 -08:00 
			
		
		
		
	Better add documentation
This commit is contained in:
		
							parent
							
								
									578f2c27f9
								
							
						
					
					
						commit
						461661112c
					
				| @ -67,23 +67,19 @@ will output | |||||||
| - 2 | - 2 | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Add object to array | ## Add new object to array | ||||||
| Given a sample.yml file of: | Given a sample.yml file of: | ||||||
| ```yaml | ```yaml | ||||||
| a: | a: | ||||||
|   - 1 |   - dog: woof | ||||||
|   - 2 |  | ||||||
| c: |  | ||||||
|   cat: meow |  | ||||||
| ``` | ``` | ||||||
| then | then | ||||||
| ```bash | ```bash | ||||||
| yq eval '.a + .c' sample.yml | yq eval '.a + {"cat": "meow"}' sample.yml | ||||||
| ``` | ``` | ||||||
| will output | will output | ||||||
| ```yaml | ```yaml | ||||||
| - 1 | - dog: woof | ||||||
| - 2 |  | ||||||
| - cat: meow | - cat: meow | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -38,11 +38,11 @@ var addOperatorScenarios = []expressionScenario{ | |||||||
| 		}, | 		}, | ||||||
| 	}, | 	}, | ||||||
| 	{ | 	{ | ||||||
| 		description: "Add object to array", | 		description: "Add new object to array", | ||||||
| 		document:    `{a: [1,2], c: {cat: meow}}`, | 		document:    `a: [{dog: woof}]`, | ||||||
| 		expression:  `.a + .c`, | 		expression:  `.a + {"cat": "meow"}`, | ||||||
| 		expected: []string{ | 		expected: []string{ | ||||||
| 			"D0, P[a], (!!seq)::[1, 2, {cat: meow}]\n", | 			"D0, P[a], (!!seq)::[{dog: woof}, {cat: meow}]\n", | ||||||
| 		}, | 		}, | ||||||
| 	}, | 	}, | ||||||
| 	{ | 	{ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user