You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: item_config_type.rs
    path of file: ./repos/genshin_artifact/mona_core/src/common
    
    the code of the file until where you have to start completion: use serde_json::json;
use crate::common::{Element, SkillType};
use crate::common::i18n::{I18nLocale, locale};

pub enum ItemConfigType {
    Float {
        min: f64,
        max: f64,
        default: f64,
    },
    Int {
        min: i32,
        max: i32,
        default: i32
    },
    IntInput {
        min: i32,
        max: i32,
        default: i32
    },
    Bool {
        default: bool
    },
    Option {
        options: &'static str, // comma separated
        default: usize
    },
    // NullOrValueInput {
    //     min: f64,
    //     max: f64,
    //     default: f64,
    // },
    FloatPercentageInput {
        default: f64,
    },
    FloatInput {
        default: f64,
    },
    Element4 {      // cryo, pyro, electro, hydro
        default: Element
    },
    Element8 {
        default: Element
    },
    Skill4 {
        default: SkillType
    }
}

pub struct ItemConfig {
    pub title: I18nLocale,
    pub name: &'static str,
    pub config: ItemConfigType,
}

impl ItemConfigType {
    pub fn to_json(&self, title: &str, name: &str) -> String {
        let j = match *self {
            ItemConfigType::Skill4 { default } => {
                json!({
                    "type": "skill4",
                    "title": title,
                    "name": name,
                    "default": default
                })
            },
            ItemConfigType::IntInput { min, max, default } => {
                json!({
                    "type": "intInput",
                    "title": title,
                    "name": name,
                    "min": min,
                    "max": max,
                    "default": default
                })
            },
            ItemConfigType::Element4 { default } => {
                json!({
                    "type": "element4",
                    "title": title,
                    "name": name,
                    "default": default
                })
            },
            ItemConfigType::Element8 { default } => {
                json!({
                    "type": "element8",
                    "title": title,
                    "name": name,
               
    
    pub fn to_json(&self, title: &str, name: &str) -> String {
        let j = match *self {
            ItemConfigType::Skill4 { default } => {
                json!({
                    "type": "skill4",
                    "title": title,
                    "name": name,
                    "default": default
                })
            },
            ItemConfigType::IntInput { min, max, default } => {
                json!({
                    "type": "intInput",
                    "title": title,
                    "name": name,
                    "min": min,
                    "max": max,
                    "default": default
                })
            },
            ItemConfigType::Element4 { default } => {
                json!({
                    "type": "element4",
                    "title": title,
                    "name": name,
                    "default": default
                })
            },
            ItemConfigType::Element8 { default } => {
                json!({
                    "type": "element8",
                    "title": title,
                    "name": name,
                    "default": default
                })
            },
            ItemConfigType::FloatPercentageInput { default } => {
                json!({
                    "type": "floatPercentageInput",
                    "title": title,
                    "name": name,
                    "default": default
                })
            },
            ItemConfigType::FloatInput { default } => {
                json!({
                    "type": "floatInput",
                    "title": title,
                    "name": name,
                    "default": default
                })
            }
            ItemConfigType::Float { min, max, default } => {
                json!({
                    "type": "float",
                    "title": title,
                    "name": name,
                    "min": min,
                    "max": max,
                    "default": default
                })
            },
            ItemConfigType::Int { min, max, default } => {
                json!({
                    "type": "int",
                    "title": title,
                    "name": name,
                    "min": min,
                    "max": max,
                    "default": default
                })
            },
            ItemConfigType::Bool { default } => {
                json!({
                    "type": "bool",
                    "title": title,
                    "name": name,
                    "default": default
                })
            },
            ItemConfigType::Option { options, default } => {
                let temp: Vec<&str> = options.split(",").collect();
                json!({
                    "type": "option",
                    "title": title,
                    "name": name,
                    "default": default,
                    "options": temp
                })
            }
        };

        j.to_string()
    }