Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#MVC对象语法_C#_Asp.net Mvc_Jwt - Fatal编程技术网

C#MVC对象语法

C#MVC对象语法,c#,asp.net-mvc,jwt,C#,Asp.net Mvc,Jwt,我试图使用下面github链接中的JWT编码函数。此JWT由Google Wallet使用,令牌的最后一部分是一个对象。有人能帮我找到“请求”部分的正确语法吗。我在visual studio编辑器中遇到语法错误 public static string CreateJWT(int JobID) { var payload = new Dictionary<string, object>() { { "iss", "171

我试图使用下面github链接中的JWT编码函数。此JWT由Google Wallet使用,令牌的最后一部分是一个对象。有人能帮我找到“请求”部分的正确语法吗。我在visual studio编辑器中遇到语法错误

         public static string CreateJWT(int JobID)
   {
       var payload = new Dictionary<string, object>() {

            { "iss", "17114776323338359428" },
            { "aud", "Google" },
            { "typ", "google/payments/inapp/item/v1" },
            { "exp", "1309988959" },
            { "iat", "1409988959" },
            { "request", 
                  "name", "Piece of Cake",
                  "description", "Virtual chocolate cake to fill your virtual tummy",
                  "price", "10.50",
                  "currencyCode", "USD",
                  "sellerData", "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j" 
            }

        };

        var secretKey = "s_F084...";
        string token = JWT.JsonWebToken.Encode(payload, secretKey, JWT.JwtHashAlgorithm.HS256);
        return token;
   }
公共静态字符串CreateJWT(int-JobID)
{
var payload=newdictionary(){
{“iss”,“17114776323338359428”},
{“aud”,“Google”},
{“typ”,“google/payments/inapp/item/v1”},
{“exp”,“1309988959”},
{“iat”,“1409988959”},
{“请求”,
“名字”,“小菜一碟”,
“描述”,“填充虚拟肚子的虚拟巧克力蛋糕”,
“价格”,“10.50”,
“货币代码”、“美元”,
“卖方数据”,“用户id:1224245,报价代码:3098576987,附属公司:aksdfbovu9j”
}
};
var secretKey=“s_F084…”;
string token=JWT.JsonWebToken.Encode(有效负载,secretKey,JWT.JwtHashAlgorithm.HS256);
返回令牌;
}

不确定是否就是这个。。但我要试试看

你有
字典
。。但在这里:

{ "request", // missing "object" part..
    { "name", "Piece of Cake" },
    { "description", "Virtual chocolate cake to fill your virtual tummy" },
    { "price", "10.50" },
    { "currencyCode", "USD" },
    { "sellerData", "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j" } 
}
或许可以尝试将其更改为:

{ "request", new Dictionary<string, object>() { // another dictionary.
        { "name", "Piece of Cake" },
        { "description", "Virtual chocolate cake to fill your virtual tummy" },
        { "price", "10.50" },
        { "currencyCode", "USD" },
        { "sellerData", "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j" } 
    }
}
{“请求”,新建字典(){//另一个字典。
{“名字”,“小菜一碟”},
{“描述”,“虚拟巧克力蛋糕填满你的虚拟肚子”},
{“价格”,“10.50”},
{“货币代码”,“美元”},
{“sellerData”,“用户id:1224245,报价代码:3098576987,附属公司:aksdfbovu9j”}
}
}

我想这不是初始化
键值对的有效方法:

你是说像这样充满活力的东西吗

        { "request", new {
              name = "Piece of Cake",
              description = "Virtual chocolate cake to fill your virtual tummy",
              price = "10.50",
              currencyCode = "USD",
              sellerData = "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j" 
            }
        }

下面是我正在使用的JWT库:如果您告诉我们Visual Studio抱怨什么,可能会有所帮助..Visual Studio在“请求”前面的{下放了一条蓝线文本。悬停错误代码抱怨“没有过载…”,但我认为错误消息并不准确,我不认为github代码是用来处理负载定义内的对象的。似乎没有C#/Google Wallet的JWT编码示例。我猜github的JWT代码不是用来处理p中的对象的谷歌正在寻找一个“请求”对象作为其JWT的最后一个参数。
        { "request", new {
              name = "Piece of Cake",
              description = "Virtual chocolate cake to fill your virtual tummy",
              price = "10.50",
              currencyCode = "USD",
              sellerData = "user_id:1224245,offer_code:3098576987,affiliate:aksdfbovu9j" 
            }
        }