add to_json method for C arrays
If the array can be converted to basic_json::string_t, the overload in this commit is not chosen.
This commit is contained in:
		
							parent
							
								
									100bf3ef2c
								
							
						
					
					
						commit
						dbebf8de47
					
				
					 3 changed files with 511 additions and 1031 deletions
				
			
		| 
						 | 
				
			
			@ -190,6 +190,20 @@ TEST_CASE("value conversion")
 | 
			
		|||
#endif
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        SECTION("built-in arrays")
 | 
			
		||||
        {
 | 
			
		||||
          const char str[] = "a string";
 | 
			
		||||
          const int nbs[] = {0, 1, 2};
 | 
			
		||||
 | 
			
		||||
          json j2 = nbs;
 | 
			
		||||
          json j3 = str;
 | 
			
		||||
 | 
			
		||||
          auto v = j2.get<std::vector<int>>();
 | 
			
		||||
          auto s = j3.get<std::string>();
 | 
			
		||||
          CHECK(std::equal(v.begin(), v.end(), std::begin(nbs)));
 | 
			
		||||
          CHECK(s == str);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        SECTION("std::deque<json>")
 | 
			
		||||
        {
 | 
			
		||||
            std::deque<json> a = j.get<std::deque<json>>();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue