对于“JSON输出不写了”答案 https://knowledge.亚搏在线safe.com/questions/21185/json-output-not-written.html 对于这个问题的答案,最新的“JSON输出不写” 通过回答隆 https://knowledge.亚搏在线safe.com/answers/21286/view.html

一种可能的方法是使用JSONFragmenter和ListIndexer的组合

JSONFragmenter

  • JSON Query: json[*]
  • Load Keys as Attributes: Yes
  • Recursively Flatten Objects/Arrays: Yes
  • Attributes to Expose: id, routeSections{}.name

ListIndexer

  • List Attribute: routeSections{}
  • List Index: 0

注意:如果“routeSections”数组是空的,所得到的“名称”将是根对象的“名称”的值,因为根对象还具有称为“名称”部件。如果有可能是这样的情况下,检查“routeSections {}”的ListIndexer前元件的数量。

#我没有想到的是我以前的答案已经被移动到第一页的顶部。

周一,2015年12月14日六时57分57秒GMT
通过hellblazer回答 https://knowledge.亚搏在线safe.com/answers/21284/view.html

关于对JSON- JSON查询[*]不被提取[ “routeSections”] [0],现在的 “身份证”。仅是阵列中的元素被提取[“routeSelections”]。在“id”为不是阵列的一部分,但需要提取。我试着使用JSON [*] [ “routeSections”] [0] [ “ID”],“ID”,ID,我也尝试过使用2 JSONFragmenter,一为 “ID” 等的名称,并合并他们。无论是方式 id didn't work. Can we have a better solution than that?

周一,2015年12月14日6时33分29秒GMT hellblazer
通过hellblazer回答 https://knowledge.亚搏在线safe.com/answers/21280/view.html

谢谢。这是惊人的:)这正是我应该做的。

周一,2015年12月14日五时44分43秒GMT hellblazer
通过回答隆 https://knowledge.亚搏在线safe.com/answers/21279/view.html

OK,尝试用这些参数设置JSONFragmenter。

  • JSON Query: json["routeSections"][0]
  • Load Keys as Attributes: Yes
  • Attributes to Expose: name (and other key names which you want to expose)

查询提取“routeSections”数组的第一元素(索引= 0)。

如果原始JSON数据是一个包含多个对象的阵列(即[{...},{...},...]),与此查询替换JSON查询。

JSON [*] [ “routeSections”] [0]

周一,2015年12月14日5点20分十八秒GMT
通过hellblazer回答 https://knowledge.亚搏在线safe.com/answers/21278/view.html

你好@takashi谢谢轴承我的建议和耐心。

该文本文件。我已只是提取的信息(30K一行)之一。在这里,我想提取的“名”,在这个个案“Brent Cross购物中心 - 埃德蒙顿绿色公交站”。一般情况下,无论是在“routesections”数组部分将具有相同的“名字”。我想提取的第一个。我们怎样才能做到这一点?

周一,2015年12月14日四点50分51秒GMT hellblazer
通过回答隆 https://knowledge.亚搏在线safe.com/answers/21219/view.html

您发布的文本只包含一个JSON对象,其中包含一个名为“名”和两个数组成员称为“routeSections”和“serviceTypes”串部件。这些阵列中的每个元素还含有一种叫“名”的成员。你想要哪个对象提取?

这是您发布的JSON对象。

{" $类型”:“Tfl.Api.Presentation.Entities。线,Tfl.Api.Presentation.Entities", "id" : "102", "name" : "102", "modeName" : "bus", "created" : "2015-12-07T14:16:21.757", "modified" : "2015-12-07T14:16:21.757", "lineStatuses" : [], "routeSections" : [ { "$type" : "Tfl.Api.Presentation.Entities.MatchedRoute, Tfl.Api.Presentation.Entities", "name" : "Brent Cross Shopping Centre - Edmonton Green Bus Station", "direction" : "inbound", "originationName" : "Brent Cross Shopping Centre", "destinationName" : "Edmonton Green Bus Station", "originator" : "490004282D", "destination" : "490009983A", "serviceType" : "Regular" }, { "$type" : "Tfl.Api.Presentation.Entities.MatchedRoute, Tfl.Api.Presentation.Entities", "name" : "Edmonton Green Bus Station - Brent Cross Shopping Centre", "direction" : "outbound", "originationName" : "Edmonton Green Bus Station", "destinationName" : "Brent Cross Shopping Centre", "originator" : "490009983G", "destination" : "490004282A", "serviceType" : "Regular" }, { "$type" : "Tfl.Api.Presentation.Entities.MatchedRoute, Tfl.Api.Presentation.Entities", "name" : "Brent Cross Shopping Centre - Edmonton Green Bus Station", "direction" : "inbound", "originationName" : "Brent Cross Shopping Centre", "destinationName" : "Edmonton Green Bus Station", "originator" : "490004282D", "destination" : "490009983A", "serviceType" : "Regular" }, { "$type" : "Tfl.Api.Presentation.Entities.MatchedRoute, Tfl.Api.Presentation.Entities", "name" : "Edmonton Green Bus Station - Brent Cross Shopping Centre", "direction" : "outbound", "originationName" : "Edmonton Green Bus Station", "destinationName" : "Brent Cross Shopping Centre", "originator" : "490009983G", "destination" : "490004282A", "serviceType" : "Regular" } ], "serviceTypes" : [ { "$type" : "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities", "name" : "Regular", "uri" : "/Line/Route?ids=102&serviceTypes=Regular" } ] }
周五,2015年12月11日14时02分29秒GMT
通过hellblazer回答 https://knowledge.亚搏在线safe.com/answers/21218/view.html

nameextract.txt

I have attached the file in text format.What I want is to extract "name" which is, in this case"Edmonton Green Bus Station - Brent Cross Shopping Centre".

周五,2015年12月11日12时46分12秒GMT hellblazer
通过回答隆 https://knowledge.亚搏在线safe.com/answers/21217/view.html

I'm not sure why the features cannot be filtered by the "name" attribute value.Could you please describe the situation in more detail?

周五,二零一五年十二月十一日12时07分02秒GMT
通过hellblazer回答 https://knowledge.亚搏在线safe.com/answers/21215/view.html

Exactly, but the the "name", unlike others is not getting filtered by itself, i can't understand why !!!

周五,2015年12月11日十一时53分25秒GMT hellblazer
通过回答隆 https://knowledge.亚搏在线safe.com/answers/21214/view.html

A simple way is to filter the features by the "name" attribute value after flattening the JSON objects.For example:

Tester: name Matches Regex ^\d+$

This regular expression matches a string consisting of numbers only.

周五,2015年12月11日11时40分06秒GMT
通过hellblazer回答 https://knowledge.亚搏在线safe.com/answers/21212/view.html

Thanks Takashi for the advice.It was really helpful.

On a way ahead of that, if you see the file, there are two "name", which we need to extract.The first is having a number but the other is have real name (not the number).Can we extract "name" which does not have the number.It is giving a problem since its not an attribute, but a JSON file.Even when I use ListExploder with name{}, the output is null and gives blank output.

Thanks

周五,二零一五年十二月十一日十一点21分33秒GMT hellblazer
通过回答隆 https://knowledge.亚搏在线safe.com/answers/21188/view.html

The response body is a JSON array.You have to use the JSONFragmenter to transform elements of the array into individual JSON objects, before flattening with the JSONFlattener.The JSONFormatter is not essential to do that.

Seehereto learn more about the structure of JSON objects.

周五,2015年12月11日6时04分04秒GMT
通过回答隆 https://knowledge.亚搏在线safe.com/answers/21186/view.html

你好,

Firstly check the result from the JSONFlattener with the Inspector (Feature Information window of Data Inspector).

In addition, I don't think you need to use the JSONFormatter before flattening a valid JSON object.

Takashi

周五,二零一五年十二月十一日5时17分22秒GMT