json-server icon indicating copy to clipboard operation
json-server copied to clipboard

Error: Type of "lastModified" (number) is not supported. Use objects or arrays of objects.

Open jdk1900 opened this issue 2 years ago • 4 comments

Hi all, I followed the steps but I get this message:

image

Any ideas what might be wrong ?

Thanks.

jdk1900 avatar Jan 24 '23 19:01 jdk1900

same issue !! did you solved the issue ?? Screenshot from 2023-02-20 21-31-55

rifkan-py avatar Feb 20 '23 16:02 rifkan-py

No! I also didn’t get a response.

From: Mohamed Rifkan @.> Sent: Monday, February 20, 2023 5:03 PM To: typicode/json-server @.> Cc: Dimitris Krallis @.>; Author @.> Subject: Re: [typicode/json-server] Error: Type of "lastModified" (number) is not supported. Use objects or arrays of objects. (Issue #1400)

same issue !! did you solved the issue ?? [Screenshot from 2023-02-20 21-31-55]https://user-images.githubusercontent.com/59793466/220153738-a28f7973-aa14-4cdd-a273-149a7966d6a9.png

— Reply to this email directly, view it on GitHubhttps://github.com/typicode/json-server/issues/1400#issuecomment-1437242775, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOIZKMAJPMDAYFRA6WJTGMDWYOISBANCNFSM6AAAAAAUFO35Q4. You are receiving this because you authored the thread.Message ID: @.@.>>

jdk1900 avatar Feb 20 '23 18:02 jdk1900

One could possibly help diagnose if you attached your db.json to the issue

ericnewton76 avatar Mar 21 '23 16:03 ericnewton76

Hi @jdk1900 ,

Thank you for reaching out. It appears that you're encountering an issue where JSON Server is not recognizing a field with a numeric value (lastModified) as valid data. This is likely because JSON Server expects data to be structured as objects or arrays of objects. Standalone primitive data types like numbers or strings directly under the root are not supported by default.

To resolve this, you can encapsulate your lastModified field within an object. For example, instead of having: { "lastModified": 123456789 } You should structure your db.json like this: { "info": { "lastModified": 123456789 } } This way, lastModified becomes a property of an object, which is compatible with JSON Server's expected data format. If lastModified is meant to be a global property, you could name the enclosing object something like metadata or info.

MadhuSaini22 avatar Dec 26 '23 08:12 MadhuSaini22