Skip to content

Instantly share code, notes, and snippets.

@pinglamb
Created November 4, 2011 06:39
Show Gist options
  • Save pinglamb/1338795 to your computer and use it in GitHub Desktop.
Save pinglamb/1338795 to your computer and use it in GitHub Desktop.
damn-api Twitter API Spec
{
"host": "api.twitter.com",
"api_groups": [
{
"name": "Timelines",
"apis": [
{
"name": "GET statuses/public_timeline",
"type": "json",
"path": "/1/statuses/public_timeline.json",
"method": "GET",
"params": {
"trim_user": "*boolean",
"include_entities": "*boolean"
}
},
{
"name": "GET statuses/user_timeline",
"type": "json",
"path": "/1/statuses/user_timeline.json",
"method": "GET",
"params": {
"screen_name": "*string",
"count": "*number",
"page": "*number"
}
}
]
},
{
"name": "Tweets",
"apis": [
{
"name": "GET statuses/show/:id",
"type": "json",
"path": "/1/statuses/show/:id.json",
"method": "GET",
"url_params": {
"id": {
"value": "*number",
"required": true
}
},
"params": {
"trim_user": "*boolean",
"include_entities": "*boolean"
}
}
]
}
]
}
@pinglamb
Copy link
Author

pinglamb commented Nov 5, 2011

I posted the JS and CSS here: https://gist.github.com/1341849
By calling Javascript JSON_PRETTY(json), the json string will be converted to html for pretty printing.

@jamztang
Copy link

jamztang commented Nov 5, 2011

@pinglamb @yachi

great, will see how it integrates in the iOS project. I've made some screenshot on the sample app, have a look if free.
https://github.com/projaito/DamnAPI-iOS

@pinglamb
Copy link
Author

pinglamb commented Nov 5, 2011

Great. I added a screenshot for the Android version as well. https://github.com/projaito/DamnAPI-Android

@jamztang
Copy link

jamztang commented Nov 6, 2011

I think ios json parser also throws error when parsing "\d", "\b". did you do any preprocessing before parsing?

@pinglamb
Copy link
Author

pinglamb commented Nov 6, 2011 via email

@jamztang
Copy link

jamztang commented Nov 6, 2011

it doesn't. I have a pretty printing extension on chrome and looks like it doesnt too.

@pinglamb
Copy link
Author

pinglamb commented Nov 6, 2011

@mystcolor JT, you are right, in Android (and also the Chrome Extension) maps:

  • \d to d
  • \b to [blank]

So I escaped the backslash (\d becomes \\d). Any comment on this approach?

@pinglamb
Copy link
Author

pinglamb commented Nov 6, 2011

JT, seems it is not a good approach as \d, \b, etc have special meaning in JSON. In Android, it becomes to same situation after several conversations between String and JSON. Any other approach?

@jamztang
Copy link

jamztang commented Nov 6, 2011

@pinglamb How about using [0-9]+ instead of \d? But I don't have a solution for \b yet, maybe there's some regex can also express that?

@jamztang
Copy link

jamztang commented Nov 6, 2011

Another way maybe there's a need to specify some magic keyword for that, such as number, string, uuid, appkey.

@pinglamb
Copy link
Author

pinglamb commented Nov 6, 2011

If you really want a regexp, true|false or 0|1 can be.

I think the logic should be matching the value with magic keywords and the problem is what keywords we pick. How about we use JT's suggestion number, string, uuid, appkey and see what the final list is and later on replace them with some special symbols (maybe some prefix, i.e. ?number).

@pinglamb
Copy link
Author

pinglamb commented Nov 6, 2011

Just found that the problem of \\d becomes d eventually is because I haven't update the raw JSON path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment