zoukankan      html  css  js  c++  java
  • Knime读取Jason数据

    Knime ETL 工具 Jason数据解析到DB

    1. 下面例子是一段Jason代码

    [{"ID":1,"name":"张三","Chinese":90,"Math":80},{"ID":2,"name":"李四","Chinese":75,"Math":90},{"ID":3,"name":"王五","Chinese":68,"Math":100}]

    2. 用文本文件存储上面代码。 test_jason.txt

    3. 用File Reader控件读取以上文本文件。

     

    4.添加String to JSON控件。

    5. 添加JSON Path控件。

    注:JSON Path说明

    JSONPath is a similar to XPath alternative for JSON.

    The result can be a single value or a list of multiple values (when the path is indefinite). In case there are multiple results and the selected output type cannot handle it (not a list of the selected type, or a JSON) the execution will fail. If the result cannot be represented in the selected type, missing value will be returned.

    There are two notations, dot-notation:$.book[1].title and bracket-notation: $['book'][1]['title'] (indexing starts from 0, negative indices are relative to the last element).

    Example input:

    {"book": [
      {"year": 1999,
       "title": "Timeline",
       "author": "Michael Crichton"},
      {"year": 2000,
       "title": "Plain Truth",
       "author": "Jodi Picoult"}
    ]}
    

    Example results:
    $.book[0]
    {"year": 1999, "title": "Timeline", "author": "Michael Crichton"} (JSON or String single value)
    $.book[*].year
    [1999,2000] (JSON, Int or Real list)
    $.book[2].year
    ? (no such part)
    $.book[?(@.year==1999)].title
    Timeline (String) or "Timeline" (JSON)

    The default path ($..*) will select all possible subparts (excluding the whole JSON value).

    When you request the paths instead of values for the $.book[0].* JSONPath, you will get the paths -in bracket notation- as a list of Strings:

    • $['book'][0]['year']
    • $['book'][0]['title']
    • $['book'][0]['author']

    which are valid JSONPaths for the input JSON value.

    The filters ?(expr)can be used to select contents with specific properties, for example $..book[?(@.publisher)] selects the books that specify their publisher (@ refers to the actual element).

    It uses the jayway/JsonPath implementation.

  • 相关阅读:
    基于Freescale的主流芯片HCS08
    BizTalk Server 2010 映射器(Mapper) [ 下篇 ]
    BizTalk Server 2010 使用 WCF Service [ 中篇 ]
    Ext JS 4 Beta 1发布了
    Step by Step WebMatrix网站开发之一:Webmatrix安装
    REST WebService与SOAP WebService的比较
    BizTalk Server 2010 使用 WCF Service [ 上篇 ]
    BizTalk Server 2010 映射器(Mapper) [ 中篇 ]
    BizTalk Server 2010 映射器(Mapper) [ 上篇 ]
    ExtJS 4 Beta 2预览:Ext.Brew包
  • 原文地址:https://www.cnblogs.com/Jesse-Li/p/10033840.html
Copyright © 2011-2022 走看看