Skip to content

Instantly share code, notes, and snippets.

@jessereynolds
Created January 6, 2014 06:12
Show Gist options
  • Select an option

  • Save jessereynolds/8278928 to your computer and use it in GitHub Desktop.

Select an option

Save jessereynolds/8278928 to your computer and use it in GitHub Desktop.
ruby object to json issues
response_data =
{"contacts" =>
contacts.collect {|contact|
contact.linked_entity_ids = linked_entity_ids[contact.id]
contact
},
"linked" => {
"entities" => linked_entity_data
}
}
logger.info("response_data: #{response_data}")
Oj.default_options = { :indent => 0, :mode => :compat }
Oj.dump(response_data)
{
"contacts": [
{
"redis": {
"size": 2,
"reserved": {},
"available": [
{
"client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": null,
"command_map": {}
},
"original_client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": null,
"command_map": {}
},
"mon_owner": null,
"mon_count": 0,
"mon_mutex": {}
},
{
"client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": {
"connection": {
"signature": 29,
"req": {
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [
{}
],
"deferred_timeout": null,
"deferred_args": [
[
"reply",
1
]
]
},
"connected": true,
"reader": {},
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [],
"deferred_timeout": null,
"deferred_args": []
},
"timeout": 5.0
},
"command_map": {},
"pid": 63804
},
"original_client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": {
"connection": {
"signature": 29,
"req": {
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [
{}
],
"deferred_timeout": null,
"deferred_args": [
[
"reply",
1
]
]
},
"connected": true,
"reader": {},
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [],
"deferred_timeout": null,
"deferred_args": []
},
"timeout": 5.0
},
"command_map": {},
"pid": 63804
},
"mon_owner": null,
"mon_count": 0,
"mon_mutex": {}
}
],
"pending": []
},
"id": "515fa769-2c04-4c6c-ae7d-8ee062c7fc4e",
"logger": null,
"first_name": "Ada",
"last_name": "Sausage",
"email": "ada@example.com",
"media": {
"sms": "",
"email": ""
},
"media_intervals": {},
"media_rollup_thresholds": {},
"linked_entity_ids": null
},
{
"redis": {
"size": 2,
"reserved": {},
"available": [
{
"client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": null,
"command_map": {}
},
"original_client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": null,
"command_map": {}
},
"mon_owner": null,
"mon_count": 0,
"mon_mutex": {}
},
{
"client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": {
"connection": {
"signature": 29,
"req": {
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [
{}
],
"deferred_timeout": null,
"deferred_args": [
[
"reply",
1
]
]
},
"connected": true,
"reader": {},
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [],
"deferred_timeout": null,
"deferred_args": []
},
"timeout": 5.0
},
"command_map": {},
"pid": 63804
},
"original_client": {
"options": {
"db": 13,
"host": "127.0.0.1",
"port": 6379,
"url": null,
"scheme": "redis",
"path": null,
"timeout": 5.0,
"password": null,
"driver": "Redis::Connection::Synchrony",
"id": null,
"tcp_keepalive": 0
},
"reconnect": true,
"logger": null,
"connection": {
"connection": {
"signature": 29,
"req": {
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [
{}
],
"deferred_timeout": null,
"deferred_args": [
[
"reply",
1
]
]
},
"connected": true,
"reader": {},
"deferred_status": "succeeded",
"callbacks": [],
"errbacks": [],
"deferred_timeout": null,
"deferred_args": []
},
"timeout": 5.0
},
"command_map": {},
"pid": 63804
},
"mon_owner": null,
"mon_count": 0,
"mon_mutex": {}
}
],
"pending": []
},
"id": "29ebf8d3-e92d-431c-84a8-01e93bfe7229",
"logger": null,
"first_name": "fjkdl",
"last_name": "lskdjf",
"email": "fjkdls",
"media": {},
"media_intervals": {},
"media_rollup_thresholds": {},
"linked_entity_ids": null
}
],
"linked": {
"entities": []
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment