Returns a JSON representation of the object(s)
Questions tagged [to-json]
108 questions
17
votes
2 answers
Ruby to_json issue with error "illegal/malformed utf-8"
I got an error JSON::GeneratorError: source sequence is illegal/malformed utf-8 when trying to convert a hash into json string. I am wondering if this has anything to do with encoding, and how can I make to_json just treat \xAE as it is?
$…

ccy
- 1,385
- 6
- 17
- 27
6
votes
1 answer
Is there a way to prevent pandas to_json from adding \?
I am trying to send a pandas dataframe to_json and I am having some issues with the date. I am getting an addtional \ so that my records look like Updated:09\/06\/2016 03:09:44. Is it possible to not have this additional \ added? I am assuming…

anshanno
- 344
- 4
- 21
6
votes
1 answer
Gson toJson(), weird behavior (produce empty json)
I have problems serializing / deserializing this class with Gson:
public class Test {
@SerializedName("id")
private String mId;
public String getId() { return mId; }
public static Test fromJson(String json) { return new…

Tim Autin
- 6,043
- 5
- 46
- 76
6
votes
3 answers
JSON object != JavaScript object?
For convenience I wrote a simple toJSON prototype, for handling JSON that I know to be safe:
String.prototype.toJSON = function () {
return JSON.parse(this.valueOf());
};
I am using it in testing my web-services. Unfortunately even with this…

A T
- 13,008
- 21
- 97
- 158
5
votes
1 answer
How to fix "OverflowError: Unsupported UTF-8 sequence length when encoding string"
Getting follwoing error while converting pandas dataframe to json
OverflowError: Unsupported UTF-8 sequence length when encoding string
this is code to
bytes_to_write = data.to_json(orient='records').encode()
fs =…

Kavya shree
- 312
- 1
- 7
- 24
4
votes
1 answer
'OverflowError: Maximum recursion level reached' while exporting to json from pandas
I have a pandas pf with these types:
id 14 non-null int64
class 14 non-null int64
action.start 6 non-null float64
action.end 6 non-null float64
action.text 6 non-null object
action.lemma …

Roy Granit
- 325
- 2
- 20
4
votes
1 answer
How to merge Aeson objects?
I have a list of aeson objects like this
[object ["key1" .= "value1"], object ["key2" .= "value2"]]
and I want to merge them as a single aeson object like this
object ["key1" .= "value1", "key2" .= "value2"]
This is quite standard when working…

Batou99
- 869
- 10
- 19
3
votes
4 answers
Create an empty array and send it to Firestore with an empty value in Flutter?
I want to create an empty array in Firestore while posing a feed. But the array is showing null in Firestore. Here is my code. Please help.
class FeedModel {
final String imgUrl;
final String desc;
final String authorName;
…

TB13
- 367
- 13
- 23
3
votes
1 answer
Nesting a group of columns with a new header in the JSON serialization
I have a Pandas dataframe of this kind
start end compDepth compReleaseDepth compMeanRate
0 0.0 0.62 58.0999985 1.5 110
1 0.66 1.34 57.1399994 3 94
2 1.42 2.1 57.1399994 …

dimstudio
- 154
- 9
3
votes
1 answer
How to convert pandas Series to desired JSON format?
I am having the following data on which I need to do apply aggregation function followed by groupby.
My data is as follows:…

Saranya
- 786
- 1
- 6
- 20
3
votes
1 answer
How to create json encodable classes in dart
This question is related to this post.
I tried the following code:
import 'dart:convert';
/*server side Post class */
class Post {
int post_id;
String title;
String description;
DateTime posted_at;
DateTime last_edited;
String user;
…

Lukasz
- 2,257
- 3
- 26
- 44
3
votes
1 answer
Convert XML to JSON using org.apache.commons.json.utils.XML toJson - Changes empty element to "true"
I'm trying to to convert an xml string to Json in Java.
Here is a sample code:
import org.apache.commons.json.utils.XML;
String test = "val1 ";
InputStream is = new…

Ali
- 808
- 2
- 11
- 20
2
votes
1 answer
Split with Regex before sequence appears
I have a text file with following content:
Test, [636,13,"be738jsk","some, text",js]
I want to read this content into an Array. I currently use JavaScript with regex to split into substrings directly into an array.
As regex i…

Henning
- 39
- 8
2
votes
1 answer
Converting Pandas DataFrame to JSON
I've data stored in pandas dataframe and I want to convert tat into a JSON format. Example data can be replicated using following code
data = {'Product':['A', 'B', 'A'],
'Zone':['E/A', 'A/N', 'E/A'],
'start':['08:00:00', '09:00:00',…

Lopez
- 461
- 5
- 19
2
votes
1 answer
How to add comma between JSON elements using Spark Scala
I'm loading a table data into a dataframe and creating multiple JSON part files. The structure of the data is good, but the elements in JSON are not separated by commas.
This is the output:
{"time_stamp":"2016-12-08…

venkatesh
- 23
- 3