Returns a JSON representation of the object(s)
Questions tagged [to-json]
108 questions
1
vote
1 answer
How do I update values in a json string using jq?
I have a JSON file with content this:-
{
"content":…

mukesh yadav
- 11
- 2
1
vote
1 answer
to_json in pyspark is exluding null values, but I need the null values as blank
I am converting a struct column in dataframe to json column using to_json in pyspark, but null values in few of the struct fields are ignored in json, I dont want the null values to be ignored.

Ramya M S
- 21
- 4
1
vote
2 answers
Pandas to_json date format is changing
I have this dataframe with start_date and end_date
and when i convert to json using to_json using this line
json_data = df.to_json(orient='records')
now if i print json_data the start_date is getting converted from yyyy-mm-dd to integer…

Mahesh
- 1,117
- 2
- 23
- 42
1
vote
3 answers
How to display json without column names pandas/python?
We query a df by below code:
json.loads(df.reset_index(drop=True).to_json(orient='table'))
The output is:
{"index": [ 0, 1 ,2, 3, 4],
"col1": [ "250"],
"col2": [ "1"],
"col3": [ "223"],
"col4": [ "2020-06-12 14:55"]
}
We need the output should…

Elsa
- 1
- 1
- 8
- 27
1
vote
1 answer
pandas groupby and convert to json of defined schema
I have below pandas df :
id mobile
1 9998887776
2 8887776665
1 7776665554
2 6665554443
3 5554443332
I want to group by on id and expected results as below :
id mobile
1 [{"9998887776": {"status": "verified"}},{"7776665554":…

j '
- 191
- 1
- 2
- 12
1
vote
1 answer
Write JSON with multiple inputs in R
I have a tibble and a list which I would like to write to a json file.
# A tibble: 2 x 12
i n c x
1 NYC New York City United States LON,271;BOS,201
2…

jaksco
- 423
- 7
- 18
1
vote
0 answers
Does pandas to_json have an encoding parameter?
I want to make a dataframe a json object.
For example,
function f():
...
...
...
return dataframe.to_json(orient='records',force_ascii=False)
but to_json does not have encoding paramter like to_csv
How do I encode with utf-8 in the…

KiWiChoco
- 53
- 1
- 5
1
vote
3 answers
Is it possible to change order of attributes when toJson()?
Let's take this example. I have a pojo class as below.
public class MyRecord{
private String name;
private String id;
//constructors and getters,setters
}
when I get the toJson(new MyRecord("MyName","myId") output for above I can…

Supun Wijerathne
- 11,964
- 10
- 61
- 87
1
vote
1 answer
Python to Javascript JSON objects (Flask)
I am trying to create a simple Flask app where an array of integers is generated on the server and sent to the client. I want to view the array of integers in the console. Here is some sample (working) code in app.py:
from flask import Flask,…

codersun3
- 165
- 2
- 4
- 13
1
vote
1 answer
Using to_json gives me illegal character
I passed a ruby variable to javascript using the to_json method, but the console returns me an error saying "SyntaxError: illegal character" for the following line:
var home = #{@home.to_json};
Does anyone knows whats wrong?

Miguel Corti
- 372
- 3
- 16
1
vote
1 answer
How to wrap Datamapper to_json response in a object-key hash
I'm working with a json parser that requires my response to be wrapped in an object-key hash. When I use DataMapper's .to_json method(datamapper/dm-serializer) the repsone I get is correct
get '/plane/all' do
@plane = Plane.all(:order =>…

PolitikP
- 311
- 3
- 5
1
vote
2 answers
How can I make Knockout.js not invoke functions when I call ko.toJS()
I've been using knockout.js for months now and only just realized it invokes functions when calling ko.toJS when serializing my model.
This can lead to obvious problems like infinite loop, and at worst dangerous data corruption if a function with…

Simon_Weaver
- 140,023
- 84
- 646
- 689
1
vote
1 answer
Javascript: Date().toJSON() changes date
> new Date().toJSON() = "2013-11-21T03:58:17.178Z"
>new Date() = Wed Nov 20 2013 19:58:20 GMT-0800 (PST)
Why changing the representation changes the date format?

daydreamer
- 87,243
- 191
- 450
- 722
1
vote
1 answer
Syntax error in as_json when using multi level :include
I've got two models that are connected through a third one:
Playlist has_many :song_in_playlists, :dependent => :destroy
has_many :songs, :through => :song_in_playlists
Song has_many :song_in_playlists, :dependent => :destroy
has_many…

kah
- 170
- 1
- 12
0
votes
1 answer
how to write null values of pysprak dataframe using toJSON() , as the key where values are null are getting dropped
when I am trying to write a spark dataframe as a json file , the column which have null values is getting dropped from json string , I would like to save the key as it is with null value .
Below is the code :
where key "Six" has value as None for…

defnoteg
- 11
- 3