Questions tagged [to-json]

Returns a JSON representation of the object(s)

108 questions
0
votes
0 answers

The method 'doc' isn't defined for the type 'CollectionReference'

I am getting a few error in my project. Can you help me? The argument type 'StreamTransformer' can't be assigned to the parameter type 'StreamTransformer'. The method 'doc' isn't defined for the type…
0
votes
1 answer

how to add a new key to change the shape of json in python

I have the following json (loaded from a pandas dataframe): [{ "id": "fc29706f-e041-46f6-88ff-cbab891da63c", "account": "21", "date": "2021-12-06", "amount": "54.4" }, { "id": "508784e4-370d-450d-bed0-8f52da7469dd", …
john
  • 145
  • 1
  • 4
0
votes
1 answer

Conversion of dataframe to JSON

I want to convert a dataframe from this format into JSON Dataframe Table Region Province Municipality Barangay Region 1 Province 1 Municipality 1 Barangay 1 Region 1 Province 1 Municipality 1 Barangay 2 Region 1 Province 1 Municipality…
0
votes
1 answer

Pandas to_json with groupby

For a pandas dataframe like this key val1 val2 a a1 a2 a b1 b2 c c1 c2 How can I convert it to the following json? Need to group on 'key' and use its values as the keys in the json: { "a":[{"val1":"a1", …
S_S
  • 1,276
  • 4
  • 24
  • 47
0
votes
0 answers

Convert heterogeneous lists to json objects using nlohmann

I have support for recursive multi-type lists and am having trouble converting them to json objects. I have this class: class Game{ string name; //ElemtnSptr is defined below the class ListElement given below //these are all lists ElementSptr…
callum arul
  • 159
  • 6
0
votes
3 answers

Use to_json but with overall data name

I'm trying to use to_json to create a json file with python. I have it working so far to produce the following sort of output: [ { "Country": "A", "Title": "B", "Category": "C" }, { "Country": "D", …
kodikai
  • 374
  • 1
  • 10
0
votes
1 answer

Databricks hierarchical sql query output as nested json

How can I produce the following nested json output (conversation = parent, message = child) using Databricks with pySpark or SQL Desired output: { "conversation_id": 1, "conversation_detail": "between mike and angie", "messages": [ …
Michael K
  • 439
  • 3
  • 13
0
votes
0 answers

I want to convert a dataframe into a JSON with output in a specific way

I have a DF that looks something like this: studentId startime skill correct timetaken questionid 1 109670354 Algebra 0 23 22 2 109670232 Statistics 1 55 5679 1 109670111 Algebra 1 8 10111 Now I want to transform this into a JSON…
0
votes
2 answers

In JSON, how to create a basic identity of one of the value

I have no idea about JSON (nor YAML), so I would like to start with a very simple 'identity' operation: formed by a two-pair object, how can I return another JSON that makes the identity of the value of one of the two pairs? For example, given {"a":…
Theo Deep
  • 666
  • 4
  • 15
0
votes
1 answer

How can I transform a pandas df to this kind of json structure?

Let's say I have a pandas df like this: | name | color of clothing | age |occupation| | John | yellow | 34 | janitor | | Carl | red | 27 | doctor | | Claire | green | 33 | teacher | | Lisa | blue …
AzUser1
  • 183
  • 1
  • 14
0
votes
0 answers

mocha/chai testing hangs on await tojson().fromFile, postman passes

So, basically I am developing my first MERN stack project in which I have an api endpoint which resets the collection vehicles. I delete the data from the collection, then I parse the data from a csv and convert them to json and insert the new data.…
jac
  • 1
0
votes
3 answers

I cannot perform a data "toJson" operation of a model and the list in it

I cannot perform a data "toJson" operation of a model and the list in it. main model class ExampleData { ExampleData({ this.name, this.surname, this.otherList, }); String name; String surname; List
Codeguru
  • 31
  • 6
0
votes
1 answer

json conversion within pyspark: Cannot parse the schema in JSON format: Failed to convert the JSON string (big JSON string) to a data type

I'm having trouble with json conversion within pyspark working with complex nested-struct columns. The schema for the from_json doesn't seem to behave. Example: import pyspark.sql.functions as f df = spark.createDataFrame([[1,'a'],[2,'b'],[3,'c']],…
guest1
  • 46
  • 4
0
votes
1 answer

removing square brackets from JSON file in R

I am creating a JSON file in R: test <- c(list(item1 = "TEXT", item2 = as.array(list(start = 0, end = 99)))) write_json(test, path = "test.json" , auto_unbox = TRUE , null = "null") which results…
Nneka
  • 1,764
  • 2
  • 15
  • 39
0
votes
2 answers

Convert Python Pandas Dataframe to nested JSON formate

i have my data coming from database like this : Account Name Address1 State Zip Loantype expiry 100 Sam Street 5 NY NY001 E 2019 100 Sam Street 5 NY NY001 T 2020 100 Sam Street 10 NJ NJ001 E 2019 100 Sam Street…
As R
  • 23
  • 4