|
|
| version 1.65, 2024/10/20 14:30:14 | version 1.67, 2025/05/26 00:52:15 |
|---|---|
| Line 1 | Line 1 |
| /** @file | /** @file |
| Parser: @b json parser class. | Parser: @b json parser class. |
| Copyright (c) 2000-2023 Art. Lebedev Studio (http://www.artlebedev.com) | Copyright (c) 2000-2024 Art. Lebedev Studio (http://www.artlebedev.com) |
| Authors: Konstantin Morshnev <moko@design.ru> | Authors: Konstantin Morshnev <moko@design.ru> |
| */ | */ |
| Line 522 const String* Json_options::array_json_s | Line 522 const String* Json_options::array_json_s |
| result << indent; | result << indent; |
| delim = get_array_delim(json_string_recursion); | delim = get_array_delim(json_string_recursion); |
| } | } |
| result << value_json_string(i.key(), i.value() ? *i.value() : static_cast<Value&>(*VVoid::get()), *this); | result << value_json_string(String::Body::uitoa(i.index()), i.value() ? *i.value() : static_cast<Value&>(*VVoid::get()), *this); |
| } | } |
| result << "\n" << (indent=get_indent(json_string_recursion-1)) << "]"; | result << "\n" << (indent=get_indent(json_string_recursion-1)) << "]"; |
| Line 531 const String* Json_options::array_json_s | Line 531 const String* Json_options::array_json_s |
| bool need_delim=false; | bool need_delim=false; |
| for(ArrayValue::Iterator i(*array); i; i.next() ){ | for(ArrayValue::Iterator i(*array); i; i.next() ){ |
| if(need_delim) result << ",\n"; | if(need_delim) result << ",\n"; |
| result << value_json_string(i.key(), i.value() ? *i.value() : static_cast<Value&>(*VVoid::get()), *this); | result << value_json_string(String::Body::uitoa(i.index()), i.value() ? *i.value() : static_cast<Value&>(*VVoid::get()), *this); |
| need_delim=true; | need_delim=true; |
| } | } |
| result << "\n]"; | result << "\n]"; |
| Line 561 const String* Json_options::array_compac | Line 561 const String* Json_options::array_compac |
| result << indent; | result << indent; |
| delim = get_array_delim(json_string_recursion); | delim = get_array_delim(json_string_recursion); |
| } | } |
| result << value_json_string(i.key(), *i.value(), *this); | result << value_json_string(String::Body::uitoa(i.index()), *i.value(), *this); |
| } | } |
| } | } |
| result << "\n" << (indent=get_indent(json_string_recursion-1)) << "]"; | result << "\n" << (indent=get_indent(json_string_recursion-1)) << "]"; |
| Line 572 const String* Json_options::array_compac | Line 572 const String* Json_options::array_compac |
| for(ArrayValue::Iterator i(*array); i; i.next() ){ | for(ArrayValue::Iterator i(*array); i; i.next() ){ |
| if (i.value()){ | if (i.value()){ |
| if(need_delim) result << ",\n"; | if(need_delim) result << ",\n"; |
| result << value_json_string(i.key(), *i.value(), *this); | result << value_json_string(String::Body::uitoa(i.index()), *i.value(), *this); |
| need_delim=true; | need_delim=true; |
| } | } |
| } | } |
| Line 595 const String& value_json_string(String:: | Line 595 const String& value_json_string(String:: |
| options.methods->put(v.type(), method ? method : VVoid::get()); | options.methods->put(v.type(), method ? method : VVoid::get()); |
| } | } |
| if(method && !method->is_void()) { | if(method && !method->is_void()) { |
| static const String::Body sindent("indent"); | |
| Junction* junction=method->get_junction(); | Junction* junction=method->get_junction(); |
| HashStringValue* params_hash=options.params && options.indent ? options.params->get_hash() : NULL; | HashStringValue* params_hash=options.params && options.indent ? options.params->get_hash() : NULL; |
| Temp_hash_value<HashStringValue, Value*> indent(params_hash, "indent", new VString(*new String(options.indent, String::L_AS_IS))); | Temp_hash_value<HashStringValue, Value*> indent(params_hash, sindent, new VString(*new String(options.indent, String::L_AS_IS))); |
| Value *params[]={new VString(*new String(key, String::L_JSON)), &v, options.params ? options.params : VVoid::get()}; | Value *params[]={new VString(*new String(key, String::L_JSON)), &v, options.params ? options.params : VVoid::get()}; |
| Line 701 static void _string(Request& r, MethodPa | Line 702 static void _string(Request& r, MethodPa |
| for(char *c=result;*c;c++) | for(char *c=result;*c;c++) |
| if(*c=='\n') | if(*c=='\n') |
| *c=' '; | *c=' '; |
| result_body=result; | result_body=String::Body(result); |
| } | } |
| r.write(*new String(result_body, String::L_AS_IS)); | r.write(*new String(result_body, String::L_AS_IS)); |
| } | } |