| | |
| | | |
| | | // 反序列化 JSON 参数为 JObject |
| | | JObject jObject = null; |
| | | try |
| | | Dictionary<string, string> filteredProperties = new Dictionary<string, string>(); |
| | | if (jsonParams != null) |
| | | { |
| | | jObject = JObject.Parse(jsonParams); |
| | | try |
| | | { |
| | | jObject = JObject.Parse(jsonParams); |
| | | // 过滤掉数组类型的属性 |
| | | filteredProperties = jObject.Properties() |
| | | .Where(p => p.Value.Type != JTokenType.Array) |
| | | .ToDictionary(p => p.Name, p => p.Value.ToString()); |
| | | } |
| | | catch (JsonReaderException) |
| | | { |
| | | // JSON 格式错误,返回未经授权 |
| | | context.Result = new UnauthorizedResult(); |
| | | return; |
| | | } |
| | | } |
| | | catch (JsonReaderException) |
| | | { |
| | | // JSON 格式错误,返回未经授权 |
| | | context.Result = new UnauthorizedResult(); |
| | | return; |
| | | } |
| | | // 过滤掉数组类型的属性 |
| | | var filteredProperties = jObject.Properties() |
| | | .Where(p => p.Value.Type != JTokenType.Array) |
| | | .ToDictionary(p => p.Name, p => p.Value.ToString()); |
| | | filteredProperties.Add("timestamp", timestamp); |
| | | filteredProperties.Add("appKey", appKey); |
| | | |