Questions tagged [to-json]

Returns a JSON representation of the object(s)

108 questions
0
votes
1 answer

dealing with lists and arrays when using toJson function - in R

I am working with a pre-specified API definition, which I need to adhere to: "myTable": { "split": [ { "total": 0, "perItem": [ 0, 0, 0 ] } …
Nneka
  • 1,764
  • 2
  • 15
  • 39
0
votes
1 answer

Deriving Aeson type classes with two different possible types in the same field

I have an API which returns JSON results in the following form: { "data": [1, 2, 3] } The data field can be the encoding of two distinct records which are shown below: newtype ResultsTypeA = ResultsTypeA [ResultTypeA] newtype ResultsTypeB =…
Jivan
  • 21,522
  • 15
  • 80
  • 131
0
votes
1 answer

Rails Redis Cache stores empty information out of method

My user.rb (model) has the following instance method: def points_last_seven_days last_seven_days_hash_raw = self.reports.group_by_day(series: true) { |r| r.created_at } out = {} last_seven_days_hash_raw.each do |day, reports| …
Alphabetus
  • 309
  • 3
  • 12
0
votes
1 answer

PostgreSQL Format Timestamp with Timezone Offset (Australia/Sydney) as JSON/String

I would like to get a JSON object in Postgres that display timestamp with Australia/Sydney timezone offset (+10:00 or +11:00 during daylight saving), for example I would like json object returned with following…
0
votes
3 answers

Rails Adding Attributes to JSON Serializer

I had a model that should be rendered as JSON, for that I used a serializer class UserSerializer def initialize(user) @user=user end def to_serialized_json options ={ only: [:username, :id] } @user.to_json(options) …
user3755529
  • 1,050
  • 1
  • 10
  • 30
0
votes
2 answers

pandas read_json returns object instead of datetime64 on some datetime64 columns

I have a DataFrame I'd like to serialize to JSON, and be able to read it back in a DataFrame. There are 2 datetime64 columns, but one of them is being returned as an object. I'm also losing the timezone info, but I see from How do I keep the…
0
votes
0 answers

Gson.toJson() throw StackOverflowError when passing Intent

I'm developing an app and on Android 6 (SDK 23) the code below goes into StackOverflow, but removing the putExtra() works correctly. Can you help me out? Gson gson = new Gson(); Intent intent = new Intent(this, Clazz.class); intent.putExtra("EXTRA",…
Andrea
  • 172
  • 1
  • 11
0
votes
1 answer

Use Date as local, not UTC when using it from bootstrap date picker

I need to get date from an angular reactive form. Then I need to use the date, stringfy it and store it in a session storage. I would like the date to be in a format that not contains time stamp, but only the date (hence - mm/dd/yyyy or dd/mm/yyyy,…
Guy E
  • 1,775
  • 2
  • 27
  • 55
0
votes
2 answers

Is it possible to override Function.prototype.toJSON so that JSON.stringify could work with functions?

Or maybe even override some portion of JSON.parse to parse functions? This isn't time sensitive, I built work arounds in my code, but with the eval function, you would think that turning functions into strings and back would be a piece of cake.
0
votes
2 answers

DataFrame to JSON giving absurd output

I have this code eventSummary = {} eventSummary['jobClassID'] = data['jobClassID'].split() eventSummary['modelID'] =data['modelID'].split() eventSummary['startDate'] = pd.to_datetime(start).date().strftime("%Y-%m-%d").split() …
0
votes
1 answer

How do I return data from Pandas DataFrame to be returned by Django's JsonResponse?

The answer to this is probably something really simple, but after hours of searching, I really could not find it. I am trying to return a JsonResponse using Django from a pandas dataframe. One of the many things I've tried is the following: from…
Shooth
  • 83
  • 2
  • 10
0
votes
1 answer

DataFrame with JSON column: Export to JSON

I´ve got a Pandas Dataframe with a JSON Formatted Column, on export of the whole DF as JSON, the JSON-Coloumn will formated like a normal string: foo = pd.DataFrame({'a' : [1,2,3,4], 'b': ['a','b', 'c','d']}) foo['json'] = foo.apply(lambda x:…
0
votes
2 answers

Python to_json function not converting DataFrame to Json in proper format for Date Field

I am facing a problem in receiving correct date formatted data from the CSV using to_json function of pandas. import pandas as pd import json df = pd.read_csv("C:\\Users\\shubham\\Desktop\\Output\\MasterData.csv") df1 =…
shubham jain
  • 45
  • 11
0
votes
1 answer

helm toJson function orders list alphabetically

I have defined an object with a few attributes in my values.yaml file: serverOptions: defaultUrl: p1: abc p2: def cpu_request: p1: abc p2: def mem_request: p1: abc p2: def I am saving…
Naigel
  • 9,086
  • 16
  • 65
  • 106
0
votes
2 answers

Pandas 'to_json' function returning wrong format of date

I am still facing a problem in receiving correct date formatted data from the CSV using to_json fu nction of pandas. import pandas as pd import json df = pd.read_csv("C:\\Users\\shubham\\Desktop\\Output\\MasterData.csv") df1 =…
shubham jain
  • 45
  • 11