<div dir="ltr">Thanks a lot for the quick response. Looks like I'm using a bit older version.<div><br></div><div>$ file test.json<br>test.json: ASCII text</div><div><br>$ file --version<br>file-5.38<br>magic file from /etc/magic:/usr/share/misc/magic<br><br></div><div>$ cat test.json<br>[<br> {<br> "id": "123",<br> "labels": []<br> }<br>]<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 6, 2024 at 8:47 PM Christos Zoulas <<a href="mailto:christos@zoulas.com">christos@zoulas.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2024-02-06 8:39 am, Puvipavan wrote:<br>
> Hello there,<br>
> <br>
> I'm not sure whether this is a right place to ask/recommend any fixes,<br>
> please direct me to the right place, if I'm wrong.<br>
> <br>
> Following JSON is valid according to RFC 7159/8259:<br>
> <br>
> [<br>
> {<br>
> "id": "123",<br>
> "labels": []<br>
> }<br>
> ]<br>
> <br>
> But it's returning mime type as text/plain whenever there is an empty<br>
> array.<br>
> <br>
> Originally I ran into this issue while using the function finfo_file<br>
> in PHP. While debugging it, I found out that PHP is internally using<br>
> your libraries. Looks like following function expecting a value inside<br>
> an array: <a href="https://github.com/file/file/blob/master/src/is_json.c#L180" rel="noreferrer" target="_blank">https://github.com/file/file/blob/master/src/is_json.c#L180</a><br>
> <br>
> Is it expected or Am I missing something?<br>
<br>
Seems to work for me:<br>
<br>
[10:15am] 862>./file -m ../magic/magic.mgc empty-array.json<br>
empty-array.json: JSON text data<br>
[10:16am] 863>./file --mime -m ../magic/magic.mgc empty-array.json<br>
empty-array.json: application/json; charset=us-ascii<br>
[10:16am] 864>./file --version<br>
file-5.45<br>
magic file from /usr/local/share/misc/magic<br>
[10:16am] 865>cat empty-array.json<br>
[<br>
{<br>
"id": "123",<br>
"labels": []<br>
}<br>
]<br>
<br>
christos<br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Regards,<br><b>P.Puvipavan</b></div></div>