Invalid JSON:Unexpected non-whitespace character after JSONat line 2, column 1
| {"QuestionId": 9410414, "AnswerCount": 1, "Tags": "<ruby-on-rails><ruby-on-rails-3><model-view-controller><routes><belongs-to>", "CreationDate": "2012-02-23T09:38:47.513", "AcceptedAnswerId": "9410640", "Title": "Rails: Forum has_many topics, saving the association?", "Body": "<p>I might be going about this the wrong way in the first place, so I will give a bit of background first.</p>\n\n<p>As you can tell from the title, I am building a forum from scratch. I thought it was working correctly; however, I am a bit unsure as to how to update/save the forum object from within the topics \"create\" method in it's controller.</p>\n\n<p>What I tried to do:\nIn the \"New\" method, I sent the Forum's id via the routing. So on the new-topic page has a address that looks like this: \"localhost:3000/new-topic/1\". The one being the Forum's id. In the method itself, I try to attach it to the new topic object.</p>\n\n<pre><code>@topic = Topic.new\n@topic.forum = Forum.find(params[:id])\n</code></pre>\n\n<p>My create method then tries to use that forum.</p>\n\n<pre><code>@topic = Topic.new(params[:topic])\n@topic.forum.topics << @topic #Simplified down.\nif @topic.save\n @topic.forum.save\n...\n</code></pre>\n\n<p>I get the feeling that I am going about this the wrong way. I was looking at someone's tutorial and they got the forum by calling params[:forum_id] but they didn't show they routing they did to achieve that.</p>\n\n<p>How do I do this correctly and/or what is the correct way to route all of this? For the record, I do plan on using this same method for the Topic => Post association. Thanks for any help.</p>\n", "Lable": "No"} | |
| {"QuestionId": 9490260, "AnswerCount": 1, "Tags": "<c#><json><highcharts>", "CreationDate": "2012-02-28T21:48:00.390", "AcceptedAnswerId": "9575650", "Title": "Pass JSON data from a .NET WebHandler to redraw Pie Highcharts with new series data", "Body": "<p>I want to create a page displaying a default pie chart and a few buttons. When the user clicks on the buttons, the page will get new JSON data from a <code>WebHandler</code> and redraw the chart. I'm using .net 2.0, C#, web forms.</p>\n\n<p>I have this <code>WebHandler</code> <code>json.ashx</code> generating the JSON:</p>\n\n<pre><code>public void ProcessRequest (HttpContext context) { \n String data = String.Empty;\n data += \"[{\\\"Male\\\": 80.0}, {\\\"Female\\\": 20.0}]\";\n context.Response.ContentType = \"application/json\";\n context.Response.Write(data);\n}\n</code></pre>\n\n<p>Here is my script on the aspx page:</p>\n\n<pre><code> var chart = null;\n\n $(document).ready(function () {\n\n var options = {\n chart: {\n renderTo: 'container',\n defaultSeriesType: 'pie'\n },\n tooltip: {\n formatter: function () {\n return '<b>' + this.point.name + '</b>: ' + this.y + ' (' + this.percentage + '%)';\n }\n },\n plotOptions: {\n pie: {\n allowPointSelect: true,\n cursor: 'pointer',\n dataLabels: {\n enabled: true,\n color: '#000000',\n connectorColor: '#000000',\n formatter: function () {\n return '<b>' + this.point.name + '</b>: ' + this.y + ' (' + this.percentage + '%)';\n }\n }\n }\n },\n series: [{\n data: [['Yes', 60], ['No', 40]]\n }]\n\n };\n\n var chart = new Highcharts.Chart(options);\n\n\n $(\"#Gender\").click(function () {\n $.get('json.ashx', function (data) {\n options.series = data;\n var chart = new Highcharts.chart(options);\n });\n });\n\n });\n</code></pre>\n\n<p>when I click on the <code>Gender</code> button, it does not generate the new chart. How do I properly parse the JSON data and feed it to the <code>series.data</code> of the new pie chart?</p>\n", "Lable": "No"} | |
| {"QuestionId": 9519546, "AnswerCount": 1, "Tags": "<c#><asp.net><.net><user-controls><pagination>", "CreationDate": "2012-03-01T16:02:27.417", "AcceptedAnswerId": "11615051", "Title": ".NET C# - Passing parent controls to a pagination .ascx control?", "Body": "<p>On a project I'm working on, I have many <asp:ListView> controls, which are paginated using <asp:DataPager> controls. Instead of copying and pasting the controls to each .aspx page where I have a paginated list, would it be possible to break out the <asp:DataPager> controls into a reusable/modular .ascx control and create a field on it to pass in the PagedControlID?</p>\n\n<p>I've tried this in the past but couldn't not seem to target the PagedControlID in the Parent page.</p>\n\n<p>Here's what I've got so far. Any help would be much appreciated.</p>\n\n<h2>.aspx Page</h2>\n\n<pre><code><abc:Pagination ID=\"uxPagination\" ListControlID=\"uxEventListView\" runat=\"server\" />\n</code></pre>\n\n<h2>.ascx Pagination Control</h2>\n\n<pre><code><asp:DataPager ID=\"uxDataPager\" PageSize=\"1\" runat=\"server\" />\n</code></pre>\n\n<h2>.ascx.cs Pagination Control</h2>\n\n<pre><code>public partial class ABC_UserControls_Pagination : System.Web.UI.UserControl\n{\n private string listControlID;\n\n public string ListControlID\n {\n get { return listControlID; }\n set { listControlID = value; }\n }\n\n protected void Page_Load(object sender, EventArgs e)\n {\n if (!string.IsNullOrEmpty(ListControlID))\n {\n uxDataPager.PagedControlID = ListControlID;\n }\n }\n}\n</code></pre>\n", "Lable": "No"} | |
| {"QuestionId": 9604589, "AnswerCount": 2, "Tags": "<powershell><php>", "CreationDate": "2012-03-07T15:46:18.340", "AcceptedAnswerId": "9604661", "Title": "Run PHP CLI from Windows Powershell ISE", "Body": "<p>This question is regarding dollar signs \"$\" <code>$</code> in Windows PowerShell ISE.</p>\n\n<p>I have PHP CLI and want to run one liner command scripts from the prompt in Windows PowerShell ISE.</p>\n\n<p><code>php -r \"$foo = 'foo';\"</code></p>\n\n<p>Just returns <code>Parse error: parse error in Command line code on line 1</code> and I've narrowed it down to the pesky dollar sign which is significant in PowerShell. Can I escape it somehow?</p>\n\n<p>I also tried </p>\n\n<p><code>php -r '$foo = \"foo\";'</code> </p>\n\n<p>and get </p>\n\n<p><code>Notice: Use of undefined constant foo - assumed 'foo' in Command line code on line 1</code></p>\n", "Lable": "No"} | |
| {"QuestionId": 9917131, "AnswerCount": 2, "Tags": "<python><virtualenv>", "CreationDate": "2012-03-28T23:29:56.047", "AcceptedAnswerId": "9917539", "Title": "virtualenv bug?", "Body": "<p>I am trying to run the following script in my virtualenv:</p>\n\n<pre><code>(python2.7.2-gonvaled1)gonvaled@lycaon:~/.virtualenvs/python2.7.2-gonvaled1$ couchy.py\nTraceback (most recent call last):\n File \"/home/gonvaled/projects/bin/couchy.py\", line 46, in <module>\n from couchdb_support import CouchdbLists\n File \"/home/gonvaled/projects/test_project/python_modules/couchdb_support.py\", line 3615, in <module>\n from asterisk_support import AsteriskSupport\n File \"/home/gonvaled/projects/test_project/python_modules/asterisk_support.py\", line 4, in <module>\n from starpy_support import AmiCommand\n File \"/home/gonvaled/projects/test_project/python_modules/starpy_support.py\", line 7, in <module>\n from starpy import manager, fastagi, utilapplication, menu\n File \"/usr/lib/python2.5/site-packages/starpy/utilapplication.py\", line 2, in <module>\n from basicproperty import common, propertied, basic, weak\n File \"/usr/lib/python2.5/site-packages/basicproperty-0.6.12a-py2.5-linux-i686.egg/basicproperty/common.py\", line 159, in <module>\n from basictypes import datedatetime_types as ddt\n File \"/usr/lib/python2.5/site-packages/basicproperty-0.6.12a-py2.5-linux-i686.egg/basictypes/datedatetime_types.py\", line 4, in <module>\n from dateutil import parser \n File \"/usr/lib/python2.5/site-packages/python_dateutil-2.1-py2.5.egg/dateutil/parser.py\", line 8\n from __future__ import unicode_literals\nSyntaxError: future feature unicode_literals is not defined\n</code></pre>\n\n<p>So somehow python is trying to import from:</p>\n\n<pre><code>/usr/lib/python2.5/site-packages/starpy/utilapplication.py\n</code></pre>\n\n<p>This does not make any sense. My virtualenv is very clean:</p>\n\n<pre><code>(python2.7.2-gonvaled1)gonvaled@lycaon:~/.virtualenvs/python2.7.2-gonvaled1$ python\nPython 2.7.2 (default, Mar 29 2012, 00:31:29) \n[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu4)] on linux2\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import sys\n>>> sys.path \n['', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/pip-1.1-py2.7.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/Twisted-12.0.0-py2.7-linux-i686.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/zope.interface-3.8.0-py2.7-linux-i686.egg', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages/basicproperty-0.6.12a-py2.7-linux-i686.egg', '/home/gonvaled/projects/gonvaled_settings', '/home/gonvaled/django_apps', '/home/gonvaled/projects/test_project/ipc', '/home/gonvaled/projects/test_project/python_modules', '/home/gonvaled/projects/test_project/gdata', '/home/gonvaled/projects/callisto/libraries', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python27.zip', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/plat-linux2', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/lib-tk', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/lib-old', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/lib-dynload', '/usr/local/python/2.7.2/lib/python2.7', '/usr/local/python/2.7.2/lib/python2.7/plat-linux2', '/usr/local/python/2.7.2/lib/python2.7/lib-tk', '/home/gonvaled/.virtualenvs/python2.7.2-gonvaled1/lib/python2.7/site-packages']\n</code></pre>\n\n<p>And:</p>\n\n<pre><code>(python2.7.2-gonvaled1)gonvaled@lycaon:~/.virtualenvs/python2.7.2-gonvaled1$ pip freeze\nCouchDB==0.9dev\nDateUtils==0.5.1\nTwisted==12.0.0\nbasicproperty==0.6.12a\npystache==0.4.0\npython-dateutil==2.1\npytz==2012b\nsimplejson==2.4.0\nsix==1.1.0\nstarpy==1.0.0a12\nwsgiref==0.1.2\nzope.interface==3.8.0\n</code></pre>\n\n<p>So to summarize: python is importing from <code>/usr/lib/python2.5/site-packages</code> even though I am inside a virtualenv. How can this be?</p>\n", "Lable": "No"} | |
| {"QuestionId": 10119397, "AnswerCount": 2, "Tags": "<mysql><database-design>", "CreationDate": "2012-04-12T07:38:51.677", "AcceptedAnswerId": "10119466", "Title": "database design with variable columns (mysql)", "Body": "<p>I am working on a problem where I am trying to figure out the best way to design the Db tables for this. Lets say I have multiple books and each book has variable number of pages in it...I need to track page views for every book </p>\n\n<p>e.g. Book 1 = 10 pages , Book 2 = 20 pages, Book 3 and 100 pages and so on \nAs the user views each page in a book, I need to log that information.</p>\n\n<p>The motive is to come up with some aggregation numbers on the %views of each book. I should be able to say e.g. \"70% people read Book 1 upto Page 7 and then drop off\" </p>\n\n<p>I envision it as </p>\n\n<pre><code>book 1 page 1 1000 views\nbook 1 page 2 950 views\nbook 1 page 3 800 views\n.....\n...\nbook 1 page 10 50 views\n</code></pre>\n\n<p>and with this I can generate a drilldown report of sorts</p>\n\n<p>however, with variable page numbers in each book, what is the best way to store this information?</p>\n\n<p>any help would be much appreciated</p>\n", "Lable": "No"} | |