I have the JSON string format like this “[[{"name":"Column1","value":"Value1"},{"name":"Column2","value":"Value2"},{"name":"Column3","value":"Value3"}], [{"name":"Column1","value":"ValueA"},{"name":"Column2","value":"ValueB"},{"name":"Column3","value":"ValueC"}]]”
And I would like to convert it to table like:
------------------------------------------------
Column1 | Column2 | Column3
Value1 | Value2 | Value3
ValueA | ValueB | ValueC
Is there any transformer can help me to do so?
Best answer by geomancer
The JSONFragmenter creates a list (named ‘array’). You can see the list in the Feature Information window. There you can also see the array is not exposed.
It is neccessary to expose the array to proceed. Therefore you need to expose array{}.name and array{}.value in the JSONFragmenter.
After that, the easiest solution is to use the ListKeyValuePairExtractor from FME Hub to add attributes with name array{}.name and value array{}.value . The final step is to expose those attributes (Column1, Column2, Column3).
The JSONFragmenter creates a list (named ‘array’). You can see the list in the Feature Information window. There you can also see the array is not exposed.
It is neccessary to expose the array to proceed. Therefore you need to expose array{}.name and array{}.value in the JSONFragmenter.
After that, the easiest solution is to use the ListKeyValuePairExtractor from FME Hub to add attributes with name array{}.name and value array{}.value . The final step is to expose those attributes (Column1, Column2, Column3).
Thank you very much for your assistance. That really solved my blocker.
I have one more question about the ListKeyValuePairExtractor. When I try to use it, a message pops up requesting the installation of the component. The FME script is intended to run on an FME Server with a scheduler. Are there any precautions I should take when using a component like this?
Thank you for the information. Is there any possible way to use a Safe Software provided transformer to replace ListKeyValuePairExtractor? I find ListKeyValuePairExtractor very useful, but I'm concerned about any policies that might prohibit using custom transformers not provided by Safe Software.
When you open ListKeyValuePairExtractor in FME Form you can see that it is a combination of a few FME Transformers, including a PythonCaller which does most of the work.
You would have to study the Python code to ascertain the ListKeyValuePairExtractor is safe to use.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.