mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: add spa_json_begin_array/object and relaxed versions
Add spa_json_begin_array/object to replace spa_json_init+spa_json_begin_array/object This function is better because it does not waste a useless spa_json structure as an iterator. The relaxed versions also error out when the container is mismatched because parsing a mismatched container is not going to give any results anyway.
This commit is contained in:
		
							parent
							
								
									feccb882b6
								
							
						
					
					
						commit
						cd81b5f39a
					
				
					 51 changed files with 401 additions and 452 deletions
				
			
		| 
						 | 
				
			
			@ -3458,21 +3458,20 @@ static jack_uuid_t client_make_uuid(uint32_t id, bool monitor)
 | 
			
		|||
 | 
			
		||||
static int json_object_find(const char *obj, const char *key, char *value, size_t len)
 | 
			
		||||
{
 | 
			
		||||
	struct spa_json it[2];
 | 
			
		||||
	struct spa_json it[1];
 | 
			
		||||
	const char *v;
 | 
			
		||||
	char k[128];
 | 
			
		||||
 | 
			
		||||
	spa_json_init(&it[0], obj, strlen(obj));
 | 
			
		||||
	if (spa_json_enter_object(&it[0], &it[1]) <= 0)
 | 
			
		||||
	if (spa_json_begin_object(&it[0], obj, strlen(obj)) <= 0)
 | 
			
		||||
		return -EINVAL;
 | 
			
		||||
 | 
			
		||||
	while (spa_json_get_string(&it[1], k, sizeof(k)) > 0) {
 | 
			
		||||
	while (spa_json_get_string(&it[0], k, sizeof(k)) > 0) {
 | 
			
		||||
		if (spa_streq(k, key)) {
 | 
			
		||||
			if (spa_json_get_string(&it[1], value, len) <= 0)
 | 
			
		||||
			if (spa_json_get_string(&it[0], value, len) <= 0)
 | 
			
		||||
				continue;
 | 
			
		||||
			return 0;
 | 
			
		||||
		} else {
 | 
			
		||||
			if (spa_json_next(&it[1], &v) <= 0)
 | 
			
		||||
			if (spa_json_next(&it[0], &v) <= 0)
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue