4267a229创建于 2024年8月2日历史提交
/*
    Copyright (c) [2023] [squallzhao]
    fountain is licensed under APACHE LICENSE, VERSION 2.0.
    You can use this software according to the terms and conditions of the APACHE LICENSE, VERSION 2.0.
    You may obtain a copy of APACHE LICENSE, VERSION 2.0 at: https://www.apache.org/licenses/LICENSE-2.0
*/

package microservice.web.codecs
import std.convert.*
import encoding.json.*

public class  RequestJsonObject <: Object{
    var obj: Object
    public init(o: Object){
        this.obj = o
    }

    public func getString(key: String): String{
        var o  = obj as JsonObject
        if (let Some(v) <- o){
            var t = v.get(key).getOrThrow().toJsonString()
            //t = t[1,t.size-1]  //todo
            return t
        }
        return ""
    }

    public func getInt32(key: String): Int32{
        var o  = obj as JsonObject
        if (let Some(v) <- o){
            var t = v.get(key).getOrThrow().toJsonString()
            return Int32.parse(t)
        }
        return 0
    }
}