取文件里面部分内容 组合成固定 json格式(领导也不会,有人帮下吗)

OuYangRuoM 2015-08-09 10:05:50


如上面,这个文件的部分内容,在这个文件里面其实还有很多类似这种结构的内容,有的有@author 有的没有,也就是说

@android或者@iphone可能有,也可能没有,也可能只有一个。。但都是这种结构.

主要用途就是 组合成 类似下面这种json格式 ,然后保存在 mongodb里面,我现在保存json文件到mongodb已经写好了,但是
就是不知道怎么把这些内容转化成json 啊。。求教!!!!!!

现在 比如上面这个 就转换成
json 转的差不多合适的格式 ( 这个 plateform)
{
"author": "Shari",
"platform": "android iphone",
"priority": "P1",
"county": {
"android": "AU IT AR CA ZA MX",
"iPhone": "AU IT AR CA ZA MX UK BE"
},
"Type": {
"andoid": "automated",
"iphone": "automated"
},
"Scenario": "Browse L1 category from Homepage"
}

类似这种 json的格式,,其他多余的内容不要。。。


请问这个读取文件里面的内容,然后该怎么转换啊?? 这个不是单纯的json解析什么的,而是要获取组合成json格式。



...全文
166 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
你发了两个贴... 我估计我很难搞定,只是这个文件里面的数据有固定格式么 反正我没看明白你说的
OuYangRuoM 2015-08-09
  • 打赏
  • 举报
回复
引用 2 楼 jslang 的回复:
用正则表达式很好做的,你把文件的部分内容发一下。你不要发图片,那样不方便
在吗在吗在吗。。。。怎么搞怎么搞怎么搞。。搞定了要多少分都行啊
OuYangRuoM 2015-08-09
  • 打赏
  • 举报
回复
引用 2 楼 jslang 的回复:
用正则表达式很好做的,你把文件的部分内容发一下。你不要发图片,那样不方便
Feature: Search with and without keyword on Homepage and Search page, browse on Homepage @author.Shari @priority.P1 @android.automated @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX @iphone.automated @iphone.country.AU @iphone.country.IT @iphone.country.AR @iphone.country.CA @iphone.country.ZA @iphone.country.MX @iphone.country.UK @iphone.country.BE Scenario: Browse L1 category from Homepage Given I am on Homepage When I tap category icon Then I should be on HomeBrowse page When I tap All Ads Then I should be on ResultsBrowseList And ResultsBrowseList page shows "All Ads" category #description: BE need to skip 'select L1 location' step as it does not allow location picker yet @author.Brigi @priority.P1 @ipad.TBA @ipad.country.AU @ipad.country.UK @ipad.country.BE Scenario: Search from SearchPanel on ResultsSearchList Given I am on ResultsSearchList page When I open SearchPanel And I type a keyword "bmw" on SearchPanel And I select Car category on SearchPanel And I select L1 location on SearchPanel And I tap search on SearchPanel Then I should be on ResultsSearchList And ResultsSearchList contains "bmw" keyword in ad title @author.Shari @priority.P2 @android.automated @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX @iphone.TBA @iphone.country.AU @iphone.country.IT @iphone.country.AR @iphone.country.CA @iphone.country.ZA @iphone.country.MX @iphone.country.UK @iphone.country.BE Scenario: Browse leaf category from Homepage Given I am on HomeBrowse page When I tap the 2nd category on HomeBrowse page Then I should see a category list When I tap the 2nd category on the list Then I should be on ResultsBrowseList page And ResultsBrowseList page shows the selected category @author.Shari @priority.P2 @android.automated @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX @iphone.country.AU @iphone.country.IT @iphone.country.AR @iphone.country.CA @iphone.country.ZA @iphone.country.MX @iphone.country.UK @iphone.TBA Scenario: Search keyword with keyword autocomplete, select keyword without category from HomePage Given I am on HomeSearch When I type a keyword "iPhone" on HomeSearch Then I should see a autocomplete list of "iPhone" keyword And I select one keyword without category name Then I should be on ResultsSearchList And ResultsSearchList contains "iPhone" keyword in ad title @author.Brigi @priority.P2 @ipad.country.AU @ipad.country.UK @ipad.TBA Scenario: Search keyword with keyword autocomplete, select keyword without category from SearchPanel Given I am on ResultsSearchList page When I open SearchPanel And I type a keyword "iPhone" on SearchPanel And I select one keyword without category name on SearchPanel Then I should be on ResultsSearchList And ResultsSearchList contains "iPhone" keyword in ad title @author.Shari @priority.P2 @android.automated @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX @iphone.country.AU @iphone.country.IT @iphone.country.AR @iphone.country.CA @iphone.country.ZA @iphone.country.MX @iphone.country.UK @iphone.TBA Scenario: Search keyword with keyword autocomplete, select keyword with category from HomePage Given I am on HomeSearch When I type a keyword "iPhone" on HomeSearch Then I should see a autocomplete list of "iPhone" When I select one keyword with category name Then I should be on ResultsSearchList And ResultsSearchList contains "iPhone" keyword in ad title And ResultsSearchList shows the selected category @author.Brigi @priority.P2 @ipad.country.AU @ipad.country.UK @ipad.TBA Scenario:Search keyword with keyword autocomplete, select keyword with category from SearchPanel Given I am on ResultsSearchList When I open SearchPanel And I type a keyword "iPhone" on SearchPanel And I select one keyword with category name on SearchPanel Then I should be on ResultsSearchList And ResultsSearchList contains "iPhone" keyword in ad title And ResultsSearchList page shows selected category @author.Shari @priority.P2 @android.automated @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX Scenario: Search keyword with keyword autocomplete, select keyword with category on Search page - android Given I am on Search page When I type a keyword "iPhone" on Search page Then I should see autocomplete list of "iPhone" And I select one keyword with category name And I tap search button Then I should be on ResultsSearchList And ResultsSearchList contains "iPhone" keyword in ad title And ResultsSearchList shows the selected category @author.Shari @priority.P2 @android.automated @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX Scenario: Clear all attributes on Search page - android Given I am on Search page When I type a keyword "House" on HomeSearch And I select RealEstate category And I set Price Type "Amount" And I set price range from "100" to "10000" And I select Sort by Cheapest When I tap Clear All button on Search page Then I should see ClearAll popup And I tap OK button Then Keywords is cleared And Category is "All Ads" And Price Type is All And Price Range is Any And Sort by is Most Recent @author.Jane @priority.P3 @android.TBA @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX Scenario:Check change search location and category - android Given I am on Search page And I select Car category And I select a L3 location When I change the category to RealEstate And I change the location to L2 location And I can select a L2 location And I check the picture required option And I tap search button Then I should be on ResultsBrowseList|ResultsSearchList @author.Jane @priority.P3 @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX @android.TBD Scenario:Check change search location and category when network cutoff- android Given None @author.Jane @priority.P3 @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX @android.TBD Scenario:Check reset all attributes when network cutoff- android Given None #Browse case @author.Jane @priority.P2 @android.country.AU @android.country.IT @android.country.AR @android.country.CA @android.country.ZA @android.country.MX @iphone.country.AU @iphone.country.IT @iphone.country.AR @iphone.country.CA @iphone.country.ZA @iphone.country.MX @iphone.country.UK @iphone.TBD @android.TDB Scenario: Check user is able to browse through different categories Given I am on Homepage And I browse RealEstate category Then I should be on ResultsBrowseList When I tap back button And I browse car category Then I should be on ResultsBrowseList And ResultsBrowseList page shows "Car" category 每个Scenario 是唯一的,且是一个case,,就把这个文件 按一个一个case组合成json,比如第一个Scenario组成json就是 json 转的差不多合适的格式 ( 这个 plateform) { "author": "Shari", "platform": "android iphone", "priority": "P1", "county": { "android": "AU IT AR CA ZA MX", "iPhone": "AU IT AR CA ZA MX UK BE" }, "Type": { "andoid": "automated", "iphone": "automated" }, "Scenario": "Browse L1 category from Homepage" } 类似这种 json的格式,,
OuYangRuoM 2015-08-09
  • 打赏
  • 举报
回复
引用 1 楼 zzgzzg00 的回复:
java一行一行的读文件会吧? 建个Map 按照你的类别读@里的东西
读文件我知道,但是怎么读@后面的内容,组合成json呢,哥??
天际的海浪 2015-08-09
  • 打赏
  • 举报
回复
用正则表达式很好做的,你把文件的部分内容发一下。你不要发图片,那样不方便
似梦飞花 2015-08-09
  • 打赏
  • 举报
回复
java一行一行的读文件会吧? 建个Map 按照你的类别读@里的东西

87,840

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧