Questions tagged [to-json]

Returns a JSON representation of the object(s)

108 questions
0
votes
1 answer

Rails to_json including association with limit

I am rendering one record with with association like below render :json => Scheme.where("id=?", params[:id]).first .to_json(:include => { :navs => { :only => [:schemeCode,:navDate,:navValue] }}) Associations Scheme has_many …
Senthil
  • 946
  • 1
  • 14
  • 34
0
votes
0 answers

Django Using Query and to_json to plot Google Graphs

I want to plot a Google Graph to visualize the results of a query. Can anyone please help me ? I have included my code below. Thanks models.py class InventoriesApplication(models.Model): ROADMAPS = ( ('R', 'Retire'), ('SU',…
0
votes
0 answers

Object.to_json(except: []) not working as expected in Rails model without ActiveRecord

Here is my model: class ServiceRequest include ActiveModel::Model include ActiveModel::Validations include ActiveModel::Serialization extend ActiveModel::Naming attr_accessor :first_name, :last_name, :prefix, :contact_email,…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
0 answers

why day in Date() start from 2

why day must be start from 2 ?!? new Date(2014,0,2).toJSON().slice(0,10) // return: "2014-01-01" new Date(2014,0,1).toJSON().slice(0,10) // return: "2013-12-31" my browser: Google Chrome, Version 23.0.1271.97
mehrad
  • 93
  • 1
  • 4
0
votes
1 answer

Adding fields to JS array

I've added a field "max" to the JS array prototype. I'm having trouble seeing this addition when I stringify the array. I've tried to overwrite the toJSON function but to no avail. Array.prototype.max = 0; Array.prototype.toJSON = function(){ …
0
votes
1 answer

Downgrading rails project to Ruby 1.9.3 | amusing .to_json trouble

Dear stackoverflow people, I want to downgrade a rails project so it can run on rails 3 without any problems. It worked before on the newest version of rails, but the office does not want to use this one. I have trouble with rewriting this…
dejakob
  • 2,062
  • 14
  • 21
0
votes
2 answers

Using toJSON on a ember.js record, is setting one of the attributes to null

I've been messing with the ember.js todoMVC example. Got it done and working just fine, but to learn some more I started modifying it. I updated the model from this: Todos.Todo = DS.Model.extend({ title: DS.attr('string'), isCompleted:…
Ryan
  • 5,644
  • 3
  • 38
  • 66
0
votes
1 answer

Google column chart visualization from json object bug in MVC 4 C#

I have MVC 4 application with C# and i am using google visualization api column chart to do some graphics for some information. But from a week or two i have some bug with the visualization of the information : the data is okay, but the drawing is…
dlght
  • 1,406
  • 1
  • 18
  • 35
0
votes
2 answers

perl mongDB to_json howto convert an ISODate, What is the right way to serialize Datetime object

I have a mongoDB with : my $data = $newspapers->find_one({_id => 2000}); last_mdb_update is a datetime in $data and is a ISODate in mongoDB $result = to_json( $data, { ascii => 1, utf8 => 1, pretty => 1 } ); I got an error: encountered object…
Sérgio
  • 6,966
  • 1
  • 48
  • 53
0
votes
1 answer

can't seem to get rails association to limit columns with json

I have a restaurant application I am building that allows restaurants to create menus online. Right now our page loads 6 items on initial page load, and then an infinite scroll interaction takes over as they continue to scroll down the page and…
0
votes
1 answer

How to handle two nested siblings, with to_json next?

The to_json ActiveRecord docs say this for dealing with two nested models, where comments is nested in posts: konata.to_json(:include => { :posts => { :include => { :comments => { …
JZ.
  • 21,147
  • 32
  • 115
  • 192
-1
votes
1 answer

discord.js: Cannot read properties of undefined (reading 'toJSON')

Hello, I was trying to make a bot with discord.js, and following the tutorial at https://discordjs.guide. And apparently data.toJSON() wasn't recognized (even though builders are installed) deploy-commands.js: const { REST } =…
berriz44
  • 62
  • 1
  • 1
  • 13
-1
votes
1 answer

Pandas: output csv data to nested json with sorting

Given the sample CSV data below, in a pandas DataFrame, how can I output to_json as follows as_of category type subtype log: [ #sorted by timestamp {timestamp: 1618879229, action: add,…
RML
  • 63
  • 6
-1
votes
1 answer

Remove '[ from JSON when writing to file in Python

I try to write a JSON to a file to use in another program. I have a dataframe which I make into a JSON like this: jsontest = df_qnapairs.to_json(orient = 'records', force_ascii = False) The output is this Out[9]: '[{"id":1,"answer":"Status på…
Andreas
  • 91
  • 8
-1
votes
1 answer

Save DataFrames into json files and name the respective files as the string value of a column

I have a list (called temp) of DataFrames where I want to save each DataFrame in a unique JSON File and give the file the name as the string value in the DataFrame column 'symbol'. My approach is: temp[i].to_json(temp[i][[temp[i]['symbol']] +…
coding404
  • 15
  • 2
  • 5