2

usually in the owner dictionary there is a display_name value to give the username. But in a few questions it simply doesn't exist and I can't see why only those questions: eg, this excerpt from the 0.8 version on SO:

 {
      "tags": [
        "python",
        "loops",
        "nested"
      ],
      "answer_count": 2,
      "favorite_count": 0,
      "question_timeline_url": "/questions/2932214/timeline",
      "question_comments_url": "/questions/2932214/comments",
      "question_answers_url": "/questions/2932214/answers",
      "question_id": 2932214,
      "owner": {
        "user_id": 353236,
        "user_type": "unregistered",
       >>>>>>> "display_name": "Gary",<<<<<<<
        "reputation": 1,
        "email_hash": "d3615ba6c904c4519282f45ca977d3d1"
      },
      "creation_date": 1275078067,
      "last_edit_date": 1275078207,
      "last_activity_date": 1275231134,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 65,
      "score": 0,
      "community_owned": false,
      "title": "nested for loop"
    },
    {
      "tags": [
        "php",
        "mysql",
        "phpmyadmin"
      ],
      "answer_count": 0,
      "favorite_count": 0,
      "question_timeline_url": "/questions/2939102/timeline",
      "question_comments_url": "/questions/2939102/comments",
      "question_answers_url": "/questions/2939102/answers",
      "question_id": 2939102,
      "owner": {
        "user_id": 354031,
        "user_type": "registered",
        "reputation": 1,
        >>>>?????????<<<<<<<
        "email_hash": "85a9b86f777656f3d22819a0ddc0a63d"
      },
      "creation_date": 1275231134,
      "last_activity_date": 1275231134,
      "up_vote_count": 0,
      "down_vote_count": 0,
      "view_count": 1,
      "score": 0,
      "community_owned": false,
      "title": "mysql phpmyadmin, how to save date of birth that was attained through a form with the input type \"select\"(drop down)"
}

the < and > added after obviously.

Any ideas why this happens?

2
  • The lack of display_name is caused by a user not having a display name set in their profile. Incorrect usernames... do you have an example of that? May 31, 2010 at 3:35
  • No I think I just got a little confused about the incorrect username, just ignore that bit.
    – Jonathan.
    May 31, 2010 at 10:18

3 Answers 3

1

display_name should always be set now.

1

Some users don't have display names.

Related:

5
  • 1
    this doesn't address the fact that the wrong users are being associated with questions. Also the API should return the username that appears on the question on the SO site.
    – Jonathan.
    May 30, 2010 at 15:53
  • Are you referring to the userxxx names? You get those and others when a user registers an OpenID but doesn't fill in their display name. May 30, 2010 at 16:53
  • 1
    No I'm saying that whatever the name of the person displayed in the actual question thread should be returned by the API. eg in this question it says "asked 3 hours ago Jonathan 101 @ 1" it should just return the Jonathan bit as the username of the question asker. So what ever the SO site displays in the question is what appears in the JSON file.
    – Jonathan.
    May 30, 2010 at 18:41
  • @George: No, the userxxx names are for unregistered users. @Jonathan: The empty display name is for registered users, based on their OpenID, who have not entered a display name such as the one in your second question (as pointed out by S.Mark). It's related to Jeff's answer to the question I linked to above. May 30, 2010 at 23:52
  • 1
    Ok so the newbie-25 guy has asked one question. In that question it says the person who wrote that question is newbie-25. He doesn't have a display name so instead of the API returning nothing for display-nane it should return newbie-25
    – Jonathan.
    May 31, 2010 at 10:18
1

There is 2 questions in your JSON,

First one, question id : 2932214, userid : 353236, and display_name : Gary is correct

You could check at actual post here

https://stackoverflow.com/questions/2932214/adding-a-jpanel-to-another-jpanel-having-tablelayout

For Second one, user does not name display_name yet, you could confirm in his profile

https://stackoverflow.com/users/354031/newbie-25

5
  • Ok so the newbie-25 guy has asked one question. In that question it says the person who wrote that question is newbie-25. He doesn't have a display name so instead of the API returning nothing for display-nane it should return newbie-25.
    – Jonathan.
    May 31, 2010 at 10:17
  • @Jonathan, its confusing, but there is two names, in Stack Overflow db, I think. one is display_name which user explicitly set, but since it is optional many people don't put it, so Stack Overflow get username info from OpenID string or from OpenID provider, but I think they don't want to expose that part, so until now, they are rejecting those requests.
    – YOU
    May 31, 2010 at 10:36
  • I understand what everyone means by 2 names, but every user has a username, whether that's a display name or from OpenID, it's the name that appears under every question users ask. I don't understand why the API doesn't give the OID one when there no display name. It is already exposed on the site. And I could just go back to using a HTML parser and get everything from that, including the username. But this is long boring and takes up more of SO's bandwidth, and the user's download allowance. So there is no harm in returning the user's "username".
    – Jonathan.
    May 31, 2010 at 10:49
  • @Jonathan, I inclined to agree that. And yes, I can't think of there is problem with returning username from OpenID too, and its true that its already on the site. Someone need to convince them to include that. But "every user has username" isn't true, take a look this question, superuser.com/questions/37449/what-is-and-in-a-directory , you would see nothing there (no userlink, no username, may be even no userid or its gone), so best thing is not to rely on the existance of the display_name on your program.
    – YOU
    May 31, 2010 at 11:02
  • ok, but that situation is very rare, and in the rare instances that happens text like "Unknown User" can be displayed. If I'm not to rely on the display name then when there is the list of questions what should I use for the question's asker (owner)
    – Jonathan.
    May 31, 2010 at 16:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .