Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5959691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:43:15+00:00 2026-05-22T18:43:15+00:00

I have this string, which is generated by dojo.toJson() function: {page:accommodation task=viewList,language:undefined} When decoding

  • 0

I have this string, which is generated by dojo.toJson() function:

{"page":"accommodation task=viewList","language":undefined}

When decoding it with json_decode in php it returns null.

I already figured out that this is caused by the value undefined, but I am not sure if this is to be expected or if it is a bug. Is the above string not valid json? Why can’t php just convert undefined to null?

I am using PHP 5.2.10

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:43:16+00:00Added an answer on May 22, 2026 at 6:43 pm

    Because undefined is not valid JSON. JSON doesn’t have the JavaScript concept of undefined. It does have null, which is vaguely similar, but the usual thing (for better or worse) is to simply omit properties whose values would be undefined.

    I’m surprised if Dojo’s toJson produces invalid JSON like that. You might consider using Crockford’s JSON.stringify instead. If Dojo’s toJson is really doing that, I’d report it as a bug to the Dojo team.

    Update: Apparently someone did report it to them, and they closed it as invalid on the “garbage in, garbage out” theory. Not my project, but that’s just totally not how I would handle properties with undefined values… I’d omit them or throw an exception.

    Update 2: As you may know, the ECMAScript 5th edition specification defines a JSON object with parse and stringify which browsers are adding support for. The specification’s definition of JSON.stringify says “undefined values are not rendered” (Section 15.12.3, Note 2) — e.g., the property should be omitted. Perhaps if you point that out to the Dojo team, they’ll rethink their GIGO response to the bug report. Also note @Felix’s comment below: They omit function references, which also can’t be validly represented in JSON, but apply a different rule to undefined.

    Update 3: Still broken in Dojo 1.6.1. Here’s a live test of v1.6.0, which is the latest on the CDNs. I’ve also tested v1.6.1 and it’s still broken there too. (Not going to post a test page hotlinking to their download section, though, that would be rude.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string which is like this: this is "a test" I'm trying
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
I have a dynamically generated large string which I am splitting. var myString=val1, val,
I have this string 'john smith~123 Street~Apt 4~New York~NY~12345' Using JavaScript, what is the
I have this: public string Log { get { return log; } protected set
I have this: If String.IsNullOrEmpty(editTransactionRow.pay_id.ToString()) = False Then stTransactionPaymentID = editTransactionRow.pay_id 'Check for null
I have this java string: String bla = <my:string>invalid_content</my:string>; How can I replace the
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM
I have this: Dim myTemp As String myTemp = System.DateTime.Now().ToString(MMMddyyyy_HHmmss) & .pdf System.IO.File.Copy(myFile, c:\
I have a string like this: string s = This is my string; I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.