<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to reference a JSON array element with no name using a Notebook or OPENROWSET? in Fabric platform</title>
    <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131351#M26348</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="201867" data-lia-user-login="Richtpt" class="lia-mention lia-mention-user"&gt;Richtpt&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;We really appreciate your efforts and for letting us know the update on the issue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please continue using fabric community forum for your further assistance.&lt;BR /&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2026 05:34:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2026-03-13T05:34:00Z</dc:date>
    <item>
      <title>How to reference a JSON array element with no name using a Notebook or OPENROWSET?</title>
      <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5130390#M26318</link>
      <description>&lt;P&gt;I'm extremely new to notebooks and accessing data within JSON files that have been imported into a Lakehouse.&amp;nbsp; I have the following JSON schema in a file (from notebook df.printSchema()):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The Modifiers array element doesn't have a name, it just looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Modifiers": [&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;"US"&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't figure out how to reference that using a notebook or SQL's OPENROWSET.&amp;nbsp; Any ideas?&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2026 23:11:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5130390#M26318</guid>
      <dc:creator>Richtpt</dc:creator>
      <dc:date>2026-03-11T23:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a JSON array element with no name using a Notebook or OPENROWSET?</title>
      <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5130561#M26324</link>
      <description>&lt;P&gt;Modifier is an array, the value inside it is accessed by index number, not by name. firsy value is at index[0].&lt;/P&gt;&lt;P&gt;to get the value use code { df.select("PRC0Collection.Modifiers[0]").show() }&amp;nbsp;&lt;/P&gt;&lt;P&gt;May be this can help.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 06:16:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5130561#M26324</guid>
      <dc:creator>trivedisunita</dc:creator>
      <dc:date>2026-03-12T06:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a JSON array element with no name using a Notebook or OPENROWSET?</title>
      <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5130739#M26333</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="201867" data-lia-user-login="Richtpt" class="lia-mention lia-mention-user"&gt;Richtpt&lt;/a&gt;&amp;nbsp; , &lt;BR /&gt;Thanks for reaching out to the Microsoft Fabric Community forum.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If you just want to see the data in the same nested format as it appears in the JSON, you can run:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;df.select("PRCCollection.Modifiers").show()&lt;/LI-CODE&gt;
&lt;P&gt;Since both PRCCollection and Modifiers are arrays, Spark will display the result as something like [[US]]. That simply means there is an array inside another array.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you’d prefer to flatten the structure and extract the actual value, you can use explode() to expand each array level:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;from pyspark.sql.functions import explode



df2 = df.withColumn("prc", explode("PRCCollection")) \

        .withColumn("Modifier", explode("prc.Modifiers"))



df2.select("Modifier").show()&lt;/LI-CODE&gt;
&lt;P&gt;Here, the first explode() opens up the PRCCollection array, and the second one expands the Modifiers array inside it. The output will then show the value directly (for example US) instead of the nested [[US]] structure.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;For reference this is the output of df.schema() for my data&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I hope this information helps. Please do let us know if you have any further queries.&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 09:46:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5130739#M26333</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2026-03-12T09:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a JSON array element with no name using a Notebook or OPENROWSET?</title>
      <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131016#M26339</link>
      <description>&lt;P&gt;Thanks, that helps a lot and I am able to see the Modifiers values.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 14:22:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131016#M26339</guid>
      <dc:creator>Richtpt</dc:creator>
      <dc:date>2026-03-12T14:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a JSON array element with no name using a Notebook or OPENROWSET?</title>
      <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131019#M26340</link>
      <description>&lt;P&gt;Thanks but this isn't working for me.&amp;nbsp; I have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;df = spark.read.json("file1.json")&lt;/P&gt;&lt;P&gt;df.select("PRC0Collection.Modifiers[0]").show()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&amp;nbsp;&amp;nbsp;[FIELD_NOT_FOUND] No such struct field `Modifiers[0]` in `Cache_ID`, `Exp_Date`, `Modifiers`, `PSCD_ID`, `Price`, `Type`.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 14:25:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131019#M26340</guid>
      <dc:creator>Richtpt</dc:creator>
      <dc:date>2026-03-12T14:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a JSON array element with no name using a Notebook or OPENROWSET?</title>
      <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131247#M26347</link>
      <description>&lt;P&gt;That code helped a lot, but I still wasn't getting what I wanted.&amp;nbsp; Probably because I'm extremely new to PySpark (as in this is my first time using it).&amp;nbsp; I finally asked Grok how to flatten this.&amp;nbsp; I got back several responses including this one that worked perfect.&amp;nbsp; Wanted to share to close this up.&amp;nbsp; Thanks much for the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;pyspark&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;sql&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;functions&lt;/SPAN&gt; &lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;col&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;explode_outer&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;explode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;spark&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;read&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;json&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Files/test.json"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;df_deep&lt;/SPAN&gt;&lt;SPAN&gt; = (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&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ers"&lt;/SPAN&gt;&lt;SPAN&gt;)).&lt;/SPAN&gt;&lt;SPAN&gt;alias&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Modifier"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;SPAN&gt;drop&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"PRC0Collection"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"PR"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;SPAN&gt;drop&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"PRC0Collection"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Modifiers"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;display&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;df_deep&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;btw, I forgot to post my json earlier.&amp;nbsp; Here it is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;{
    "AGAG_ID": "PHKETCHMC",
    "AGIP_CAP_IND": "",
    "CSPI_HIOS_ID_NVL": "73836AK09999",
    "CSPI_ID": "AMT01234",
    "GRGR_CK": 12345,
    "IPCD_ID": "R9999",
    "PRC0Collection": [
        {
            "Cache_ID": "1462da8b",
            "Exp_Date": "12/31/9999 00:00:00.000",
            "Modifiers": [
                "US"
            ],
            "PSCD_ID": "11",
            "Price": 16336.44,
            "Type": "negotiated"
        },
        {
            "Cache_ID": "156eab34",
            "Exp_Date": "12/31/9999 00:00:00.000",
            "Modifiers": [
                "UQ"
            ],
            "PSCD_ID": "11",
            "Price": 24499.76,
            "Type": "negotiated"
        }
    ],
    "PRPR_ID": "P00000099999",
    "SEDF_CAP_IND": "N"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2026 21:37:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131247#M26347</guid>
      <dc:creator>Richtpt</dc:creator>
      <dc:date>2026-03-12T21:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference a JSON array element with no name using a Notebook or OPENROWSET?</title>
      <link>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131351#M26348</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="201867" data-lia-user-login="Richtpt" class="lia-mention lia-mention-user"&gt;Richtpt&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;We really appreciate your efforts and for letting us know the update on the issue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please continue using fabric community forum for your further assistance.&lt;BR /&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2026 05:34:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Fabric-platform/How-to-reference-a-JSON-array-element-with-no-name-using-a/m-p/5131351#M26348</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2026-03-13T05:34:00Z</dc:date>
    </item>
  </channel>
</rss>

