Foxtable(狐表)用户栏目专家坐堂 → 临时表序列化JSON时多了四个字段?


  共有2236人关注过本帖树形打印复制链接

主题:临时表序列化JSON时多了四个字段?

帅哥哟,离线,有人找我吗?
jnletao
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:941 积分:7786 威望:0 精华:0 注册:2013/7/7 13:37:00
临时表序列化JSON时多了四个字段?  发帖心情 Post By:2016/8/5 11:44:00 [只看该作者]

全局变量
以下内容为程序代码:

1 ConvertHelper
2
3 Public Class ConvertHelper
4
5 '把对象序列化为Json字符串
6 Public Shared Function ToJson(ByVal fromObject As Object) As String
7 Return Newtonsoft.Json.JsonConvert.SerializeObject(fromObject)
8 End Function
9
10 ' 把Json字符串反序列化为指定类型的对象
11 Public Shared Function FromJson(Of T)(ByVal jsonString As String) As T
12 Return Newtonsoft.Json.JsonConvert.DeserializeObject(Of T)(jsonString)
13 End Function
14
15 '字符串转换成字节数组
16 Public Shared Function EncodingToBytes(ByVal s As String, Optional encode As System.Text.Encoding = Nothing) As Byte()
17 Dim encoding As System.Text.Encoding = IIf(encode Is Nothing, System.Text.Encoding.Unicode, encode)
18 Return encoding.GetBytes(s)
19 End Function
20
21 ' 字节数组转换成字符串
22 Public Shared Function EncodingToString(ByVal bytes As Byte(), Optional encode As System.Text.Encoding = Nothing) As String
23 Dim encoding As System.Text.Encoding = IIf(encode Is Nothing, System.Text.Encoding.Unicode, encode)
24 Return encoding.GetString(bytes)
25 End Function
26
27 '把DataRow值赋值到对象的实体对象
28 Public Shared Sub FromDataRow(ByVal Row As DataRow, ByRef entity As EntityBase)
29 Dim fs As System.Reflection.PropertyInfo() = entity.Gettype.GetProperties
30 Dim f As System.Reflection.PropertyInfo
31 For Each f In fs
32 If ((Not Row.DataTable Is Nothing) AndAlso Row.DataTable.DataCols.Contains(f.Name)) Then
33 Dim o As Object = Row.Item(f.Name)
34 If (Not o Is DBNull.Value) Then
35 f.SetValue(entity, o, Nothing)
36 End If
37 End If
38 Next
39 End Sub
40
41 ' 把实体值赋值到DataRow
42 Public Sub ToDataRow(ByVal entity As EntityBase, ByRef Row As DataRow)
43 Dim fs As System.Reflection.PropertyInfo() = entity.Gettype.GetProperties
44 Dim f As System.Reflection.PropertyInfo
45 For Each f In fs
46 If ((Not Row.DataTable Is Nothing) AndAlso Row.DataTable.DataCols.Contains(f.Name)) Then
47 Dim o As Object = f.GetValue(entity, Nothing)
48 If (o Is Nothing) Then
49 Row.Item(f.Name) = DBNull.Value
50 Else
51 Row.Item(f.Name) = o
52 End If
53 End If
54 Next
55 End Sub
56 End Class
57


临时表
DataTables("JSON临时表").Fill("Sele ct TOP 1 车辆照片 As imgList,车辆类型 As modelName,年检有效期 As checktime,[_Identify] From {车辆信息}  Order by [_Identify] Desc","data",True)

JSON后多出来的四列:
"_Locked":null,"System_Sort_Temporary":null,"System_Filter_Temporary":null,"System_Filter_Unique":null

请教如何在JSON时屏蔽无关字段?

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/5 11:56:00 [只看该作者]

 无法屏蔽的。你可以生成后,截取,删除掉。

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/8/5 11:57:00 [只看该作者]

 与其这样,你还不如自己合成json字符串。循环每一行每一列即可。

 回到顶部