@@ -160,7 +160,8 @@ class t_cocoa_generator : public t_oop_generator {
160
160
void generate_cocoa_struct_validator (std::ofstream& out, t_struct* tstruct);
161
161
void generate_cocoa_struct_description (std::ofstream& out, t_struct* tstruct);
162
162
void generate_cocoa_struct_to_json (std::ofstream& out, t_struct* tstruct);
163
- void generate_cocoa_struct_to_json_method (std::ofstream& out, t_field *field, int &counter, size_t levels, bool needs_isset_test);
163
+ void generate_cocoa_struct_to_json_method (std::ofstream& out, t_field *field, int &counter, size_t levels, bool is_container_element);
164
+ void generate_cocoa_struct_to_json_method (std::ofstream& out, t_field *field, int &counter, size_t levels, bool is_container_element, bool is_map_element);
164
165
165
166
std::string function_result_helper_struct_type (t_function* tfunction);
166
167
std::string function_args_helper_struct_type (t_function* tfunction);
@@ -1668,12 +1669,22 @@ void t_cocoa_generator::generate_cocoa_struct_to_json(ofstream& out, t_struct* t
1668
1669
out << " }\n\n " ;
1669
1670
}
1670
1671
1672
+ void t_cocoa_generator::generate_cocoa_struct_to_json_method (
1673
+ std::ofstream& out,
1674
+ t_field *field,
1675
+ int &counter,
1676
+ size_t levels,
1677
+ bool is_container_element) {
1678
+ generate_cocoa_struct_to_json_method (out, field, counter, levels, is_container_element, false );
1679
+ }
1680
+
1671
1681
void t_cocoa_generator::generate_cocoa_struct_to_json_method (
1672
1682
std::ofstream& out,
1673
1683
t_field *field,
1674
1684
int &counter,
1675
1685
size_t levels,
1676
- bool is_container_element) {
1686
+ bool is_container_element,
1687
+ bool is_map_element) {
1677
1688
using boost::lexical_cast;
1678
1689
1679
1690
t_type *type = field->get_type ();
@@ -1721,7 +1732,7 @@ void t_cocoa_generator::generate_cocoa_struct_to_json_method(
1721
1732
}
1722
1733
} else if (base == t_base_type::TYPE_I16 || base == t_base_type::TYPE_I32 || base == t_base_type::TYPE_I64) {
1723
1734
string format_spec;
1724
- if (is_container_element) {
1735
+ if (is_container_element && !is_map_element ) {
1725
1736
format_spec = " @\" %@\" " ;
1726
1737
} else if (base == t_base_type::TYPE_I16) {
1727
1738
format_spec = " @\" %\" PRId16" ;
@@ -1862,7 +1873,7 @@ void t_cocoa_generator::generate_cocoa_struct_to_json_method(
1862
1873
}
1863
1874
1864
1875
indent (out, nl + 1 ) << " [builder appendString:@\" : \" ];\n " ;
1865
- generate_cocoa_struct_to_json_method (out, &fake_val_field, counter, nl + 1 , true );
1876
+ generate_cocoa_struct_to_json_method (out, &fake_val_field, counter, nl + 1 , true , true );
1866
1877
1867
1878
indent (out, nl) << " }\n " ;
1868
1879
indent (out, nl) << " [builder appendString:@\" }\" ];\n " ;
0 commit comments