Table of Contents

Class JXPath

Namespace
ZapLib.Utility
Assembly
ZapLib.dll

萬用的 dynamic xpath 取值工具

public static class JXPath
Inheritance
JXPath
Inherited Members

Methods

GetValue(dynamic, string)

依照 Xpath 從指定的 dynamic 物件取得指定位置的數值,如果路徑設定有誤或無法取得數值則會回傳 null

public static object GetValue(dynamic d, string xpath)

Parameters

d dynamic

dynamic 物件

xpath string

xpath 路徑

Returns

object

數值

GetValue(string, string)

依照 Xpath 從指定的 json 字串取得指定位置的數值,如果路徑設定有誤或無法取得數值則會回傳 null

public static object GetValue(string json, string xpath)

Parameters

json string

JSON 字串

xpath string

xpath 路徑

Returns

object

數值

ParseXPath(string)

將 Xpath 轉換成路徑 List ,依照階層排列,每個階層意義為: (field 名稱 , idx 索引位置),索引位置為 -1 時,表示直接回傳該值,否則將視為陣列取裡面特定位置的值

public static List<(string, int)> ParseXPath(string path)

Parameters

path string

XPath 字串

Returns

List<(string, int)>

依照階層排列的路徑資料