Solved

How can I read a .json into a single attribute instead of having it flattened?

  • 1 February 2022
  • 2 replies
  • 34 views

I'm trying to read a .json file into a single feature attribute.

So far all my attempts to read the json has led to it being flattened, with all json 'keys' showing up as an attribute. The reason I want to have it in one attribute is that the jsons in question are service definition for ArcGIS Online content. Essentially it gets converted into a python dictionary using json.loads(feature.getAttribute(...)).

 

One workaround I've thought of is just changing the extension of the json to .txt and reading that instead. However, I would prefer to do it a neater way, if there is one.

 

Any suggestions?

icon

Best answer by david_r 1 February 2022, 09:33

View original

2 replies

Userlevel 4

You can use the Text File reader and set it to read the whole file in at once (rather than line by line). It's not necessary to change the file extension for this to work.

You can use the Text File reader and set it to read the whole file in at once (rather than line by line). It's not necessary to change the file extension for this to work.

Hi David, thanks for your suggestion. I'll use this approach.

 

Reply