fn build_json_objects_for_group_by<T: std::fmt::Display>(
        &self,
        mut map: HashMap<String, T>,
        by: Option<String>,
        alias: String,
        default: T,
    ) -> Vec<String> {
        let mut objects = Vec::with_capacity(map.len());

        if let Some(group_by_attr) = by {
            for (key, val) in map.drain() {
                objects.push(
                    json!(
                        { format!("{}", &alias): format!("{}", val) ,
                        format!("{}", &group_by_attr): key,
                        }
                    )
                    .to_string(),
                );
            }
            if objects.len() == 0 {
                // Fill the empty object.
                objects.push(
                    json!(
                        { format!("{}", &alias): "".to_string() ,
                        format!("{}", &group_by_attr): "".to_string(),
                        }
                    )
                    .to_string(),
                );
            }
        } else {
            let val = map
                .remove(&"default".to_string())
                .unwrap_or_else(|| default);
            objects.push(
                json!({
                    format!("{}", &alias): format!("{}",val),
                })
                .to_string(),
            );
        };
        objects
    }
/// build_json_objects_for_group_by creates json objects for group by attr.
build_json_objects_for_group_by creates json objects for group by attr.
build_json_objects_for_group_by creates json objects for group by attr .
fn build_json_objects_for_group_by<T: std::fmt::Display>(
        &self,
        mut map: HashMap<String, T>,
        by: Option<String>,
        alias: String,
        default: T,
    ) -> Vec<String> {
        let mut objects = Vec::with_capacity(map.len());
        if let Some(group_by_attr) = by {
            for (key, val) in map.drain() {
                objects.push(
                    json!(
                        { format!("{}", &alias): format!("{}", val) ,
                        format!("{}", &group_by_attr): key,
                        }
                    )
                    .to_string(),
                );
            }
            if objects.len() == 0 {
                // Fill the empty object.
                objects.push(
                    json!(
                        { format!("{}", &alias): "".to_string() ,
                        format!("{}", &group_by_attr): "".to_string(),
                        }
                    )
                    .to_string(),
                );
            }
        } else {
            let val = map
                .remove(&"default".to_string())
                .unwrap_or_else(|| default);
            objects.push(
                json!({
                    format!("{}", &alias): format!("{}",val),
                })
                .to_string(),
            );
        };
        objects
    }
fn build_json_objects_for_group_by < T : std :: fmt :: Display > ( & self , mut map : HashMap < String , T > , by : Option < String > , alias : String , default : T , ) -> Vec < String > { let mut objects = Vec :: with_capacity ( map . len ( ) ) ; if let Some ( group_by_attr ) = by { for ( key , val ) in map . drain ( ) { objects . push ( json ! ( { format ( " " alias ) format ( " " val ) format ( " " group_by_attr ) key } ) . to_string ( ) , ) ; } if objects . len ( ) == 0 { // Fill the empty object. objects . push ( json ! ( { format ( " " alias ) " " to_string ( ) format ( " " group_by_attr ) " " to_string ( ) } ) . to_string ( ) , ) ; } } else { let val = map . remove ( & " " . to_string ( ) ) . unwrap_or_else ( | | default ) ; objects . push ( json ! ( { format ( " " alias ) format ( " " val ) } ) . to_string ( ) , ) ; } ; objects }
build_json_objects_for_group_by creates json objects for group by attr.
build_json_objects_for_group_by creates json objects for group by attr .
&self
map
HashMap<String, T>
by
Option<String>
alias
String
default
T