Skip to main content
Solved

Help me please to transform .json files


muzhnasto
Contributor
Forum|alt.badge.img+12

Dear,colleagues.  @ebygomm​  @nielsgerrits​ @david_r​   please help me with a .json file (reading, converting, and writing it). So the details:

1 - I have extract the names of the main folders

Tile_p502_m6014
Tile_p502_m6015

2 - then I have a .json file 

{"asset":{"version":"1.0","gltfUpAxis":"Y"},"geometricError":2965.7869354899398786,"root":{"boundingVolume":{"sphere":[2868547.6520226998254657,2203510.7712099198251963,5235902.6513763302937150,1482.8934677449699393]},"refine":"REPLACE","geometricError":2965.7869354899380596,"children":[{"boundingVolume":{"sphere":[2868210.6526993899606168,2203251.1590014300309122,5236183.9360417695716023,954.5398049977940218]},"geometricError":1909.0796099955900900,"children":[{"boundingVolume":{"sphere":[2868210.6526993899606168,2203251.1590014300309122,5236183.9360417695716023,954.5398049977940218]},"geometricError":16,"content":{"uri":"Data\/Tile_p502_m6014\/Tile_p502_m6014.json"}}]},{"boundingVolume":{"sphere":[2868861.2329204198904335,2203750.2456317897886038,5235605.0275514703243971,953.7367633961099500]},"geometricError":1907.4735267922199000,"children":[{"boundingVolume":{"sphere":[2868861.2329204198904335,2203750.2456317897886038,5235605.0275514703243971,953.7367633961099500]},"geometricError":16,"content":{"uri":"Data\/Tile_p502_m6015\/Tile_p502_m6015.json"}}]}]}}

with on this data, I need to create new .json files(for each folder its own .json file) like this:

image 

JSON-1
{"asset":{
"version":"1.0","gltfUpAxis":"Y"},
"geometricError":2965.7869354899398786,
"root":{
"boundingVolume":{
"sphere":[2868547.6520226998254657,2203510.7712099198251963,5235902.6513763302937150,1482.8934677449699393]},
"refine":"REPLACE",
"geometricError":2965.7869354899380596,
"children":[{
"boundingVolume":
{"sphere":[2868210.6526993899606168,2203251.1590014300309122,5236183.9360417695716023,954.5398049977940218]},
"geometricError":1909.0796099955900900,
"children":
[{"boundingVolume":
{"sphere":
[2868210.6526993899606168,2203251.1590014300309122,5236183.9360417695716023,954.5398049977940218]},
"geometricError":16,"content":{"uri":"Data\/Tile_p502_m6014\/Tile_p502_m6014.json"}}]}]}}
 
JSON-2
{"asset":{
"version":"1.0","gltfUpAxis":"Y"},
"geometricError":2965.7869354899398786,
"root":{
"boundingVolume":{
"sphere":[2868547.6520226998254657,2203510.7712099198251963,5235902.6513763302937150,1482.8934677449699393]},
"refine":"REPLACE",
"geometricError":2965.7869354899380596,
"children":[{
"boundingVolume":
{"sphere":[2868861.2329204198904335,2203750.2456317897886038,5235605.0275514703243971,953.7367633961099500]},
"geometricError":1907.4735267922199000,
"children":
[{"boundingVolume":
{"sphere":
[2868861.2329204198904335,2203750.2456317897886038,5235605.0275514703243971,953.7367633961099500]},
"geometricError":16,"content":{"uri":"Data\/Tile_p502_m6015\/Tile_p502_m6015.json"}}]}]}}

But I faced a problem, when i use only JsonReader-->JsonWriter scheme, I don't get the same information, that I have load into the reader.

Here it is:

[
	{
		"json_featuretype" : "JSONFeature",
		"asset.version" : "1.0",
		"asset.gltfUpAxis" : "Y",
		"geometricError" : 2965.78693548994,
		"root.boundingVolume.sphere" : 2868547.65202272203510.771209925235902.651376331482.89346774497 ],
		"root.refine" : "REPLACE",
		"root.geometricError" : 2965.786935489938
	}
]

Please do not pass by and help me to figure out what's wrong and how could i solve this problem!

PS I have attached archive with data, maybe someone can figure out))))

 

 

 

Best answer by takashi

Hi @muzhnasto​ , I would use the JSONFragmenter and the JSONUpdater, as in:jsonfragmenter-jsonupdater

View original
Did this help you find an answer to your question?

3 replies

david_r
Evangelist
  • April 23, 2021

If you need a very specific output schema, you should consider using the JSONTemplater + Text file writer. This will give you more flexibility than using the JSON writer.


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • April 24, 2021

Hi @muzhnasto​ , I would use the JSONFragmenter and the JSONUpdater, as in:jsonfragmenter-jsonupdater


muzhnasto
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • April 26, 2021

Thank you @Takashi Iijima​  thank you so much for your participation! i will examine it


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings