Returns a JSON representation of the object(s)
Questions tagged [to-json]
108 questions
0
votes
2 answers
Spark - drop duplicates inside a json array field
I share the code that I have:
// define a case class
case class Zone(id: Int, team: String, members: Int ,name: String, lastname: String)
val df = Seq (
(1,"team1", 3, "Jonh", "Doe"),
(1,"team2", 4, "Jonh", "Doe"),
…

sylvinho81
- 309
- 4
- 15
0
votes
2 answers
Converting a nested List in using Gson.tojson
I'm using Scala, but this applies to Java as well - it appears Gson is having issues converting a List nested within a case class/within another object:
case class Candy(name:String, price:Double)
case class PersonCandy(name:String, age:Int,…

NateH06
- 3,154
- 7
- 32
- 56
0
votes
1 answer
how to create a dataframe to generate json in the given format
I need to generate a json from my dataframe but I have tried many formats of df but still I am not able get the required json format.
My required json format is,
[
{
"Keyword": "Red",
"values": [
{
…

Pyd
- 6,017
- 18
- 52
- 109
0
votes
1 answer
From pandas to Json with keys
I have a Dataframe df with 11 rows and 1 column. In each row I have an array that I would convert into json but assigning to each entry in array a key.
For example,
0
0 …

user3043636
- 559
- 6
- 23
0
votes
4 answers
How to convert bean with reference bean to json in java?
I am trying to convert my bean to json via Gson. My bean (Logs) include another bean(Log) and second bean reference to first bean.
@Entity
@Table(name = "t_logs")
public class Logs {
@Id
@Column(name = "executionid")
private String…

stephan
- 271
- 1
- 4
- 24
0
votes
1 answer
ngTagsInput get and parse data from database
When I use ngTagsInput before send to database I do:
angular.toJson($scope.tags);
When I make get I receive something like this in my scope {{}}:
[{"text":"abc"},{"text":"cba"},{"text":"tag"}]
What can I do to show my tags like this:
abc, cba,…

andrzej
- 495
- 1
- 7
- 18
0
votes
0 answers
Pandas: Write dataframe to json with groupby data
I need to write data to json, but I want, that data in the strings will be ascending. But I get
"0987654321abcdef1234567890abcdef": {
"2014-06": 1,
"2016-05": 1,
"2016-09": 1,
"2016-03": 0,
"2015-02": 0,
"2016-01":…

NineWasps
- 2,081
- 8
- 28
- 45
0
votes
1 answer
Pandas: Write dataframe to json with split
I need write data to json. Problem is that I can't establish delimiter to string.
My df looks like
id date val
0 123 2015-12-12 1
1 123 2015-12-13 1
2 123 2015-12-14 0
3 123 2015-12-15 1
4 123 2015-12-16 1
5 …

NineWasps
- 2,081
- 8
- 28
- 45
0
votes
1 answer
A dataframe with two index to json in pandas
I'am trying to convert pandas' dataFrame to json.
y=pd.read_csv('testx.csv',encoding='utf-8')
y.columns = ['i','city','language','words']
del y['i']
y = y.set_index(['city','language'])
z=y.to_json(orient='index')
I've got incorrect json with [ and…

mailman_73
- 778
- 12
- 29
0
votes
1 answer
Pandas: converting pivot to JSON
I have the following Pandas pivot
Apple Green 5
Red 3
Yellow 4
Grapes Red 1
Green 3
and want to convert this data to JSON like follows:
{
Apple: {
Green : 5,
Red: 3,…

Homan Mohammadi
- 55
- 1
- 5
0
votes
2 answers
Converted json (from ArrayList) has more elements
I post what I have done, as I don't get the result.. Here I have a method which returns an ArrayList:
public ArrayList

yaylitzis
- 5,354
- 17
- 62
- 107
0
votes
2 answers
Get the path of my project's folder
In build a web application with netbeans, in some point I extract an arrayList to json format.
public void convertToJSON(ArrayList list){
ObjectMapper mapper = new ObjectMapper();
try{
mapper.writeValue(new…

yaylitzis
- 5,354
- 17
- 62
- 107
0
votes
1 answer
Getting an error on JSON.parse
I was reading an article by Derick Bailey Don’t Return A JSON Document From The toJSON Method
I was trying to convert the following JSON object into Javascript:
var userJSON = "{\"firstName\":\"Derick\",\"lastName\":\"Bailey\"}";
var parseOnce =…

Amen Ra
- 2,843
- 8
- 47
- 85
0
votes
1 answer
Serialize to json rails models with associated records
Suppose I have Folder with has_many association to File.
I had a small action where I rendered json like this
render json: folder.to_json(include: :files)
I've tried to render a bit more complicated json response with following
render json:…

S.S.J
- 353
- 1
- 7
0
votes
1 answer
need to convert a json response into java pojo where the response may return {} or [{},{}]
Need to convert a json response to a java pojo in which a field(here in the examples 'performers' ) may either be returned as {} or [{},{}] or null as shown in the examples below:
example1:performer value here is a list of datas '{}'.
{
…

A.J.K
- 1
- 2