1
ファイル内に行ごとにJSONオブジェクトとしてデータが格納されています。これをU-SQLスクリプトで抽出するには、どのような方法が良いですか?U-SQLでのJSON行の抽出
私はText Extractor(下のコードを参照)を使用していますが、JSONオブジェクトが大きくなり、文字列のサイズが128KBになっています。どんな助けでも感謝します。
サンプルデータ:
{ "prop1": "abc", "prop2": "xyz" }
{ "prop1": "def", "prop2": "uvw" }
U-SQL:
//Read (JSON Lines) line by line
@dataAsStrings =
EXTRACT jsonObjStr string
FROM @INPUT_FILE
USING Extractors.Text(delimiter:'\n');
//Use the JsonTuple function to get the Json Token of the string so it can be parsed later with Json .NET functions
@jsonify = SELECT Microsoft.Analytics.Samples.Formats.Json.JsonFunctions.JsonTuple(jsonObjStr, "prop1", "prop2") AS rec FROM @dataAsStrings;
//Extract the fields from the Json object.
@json = SELECT
rec["prop1"] AS prop1,
rec["prop2"] AS prop2
FROM @jsonify;
どこでも完了しましたか? – Steve
はい。 GitHubアセンブリにそのようなバージョンを追加することは、バックログにもあります。 –
共有できるリンクはありますか? – Steve