All Questions

Tagged with
Filter by
Sorted by
Tagged with
337 votes
5 answers
247k views

Is the order of elements in a JSON list preserved?

I've noticed the order of elements in a JSON object not being the original order. What about the elements of JSON lists? Is their order maintained?
user437899's user avatar
  • 9,029
134 votes
13 answers
301k views

Unhandled Exception: InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>

I am trying to get the JSON response from the server and output it to the console. Future<String> login() async { var response = await http.get( Uri.encodeFull("https://etrans....
harunB10's user avatar
  • 5,087
131 votes
3 answers
221k views

Python: converting a list of dictionaries to json

I have a list of dictionaries, looking some thing like this: list = [{'id': 123, 'data': 'qwerty', 'indices': [1,10]}, {'id': 345, 'data': 'mnbvc', 'indices': [2,11]}] and so on. There may be more ...
Apoorv Ashutosh's user avatar
103 votes
4 answers
430k views

Convert JSON array to Python list

import json array = '{"fruits": ["apple", "banana", "orange"]}' data = json.loads(array) That is my JSON array, but I would want to convert all the values in ...
user1447941's user avatar
  • 3,785
93 votes
8 answers
95k views

Type 'List<dynamic>' is not a subtype of type 'List<int>' where

I am new to Flutter, I try to run one GitHub project but got an error like: type List dynamic is not a subtype of type List int where. Github Link Error Line List<int> genreIds; MediaItem....
Magesh Pandian's user avatar
40 votes
6 answers
81k views

Jackson read json in generic List

I'm using Jackson in order to read json messages. One of the values that I' trying to parse is a List and another value contains the type of the data in the list. This is the structure i 've created ...
Lalao's user avatar
  • 423
32 votes
2 answers
33k views

How can I define a list field in django rest framework?

Let's say I have a class class Tags(object): tags = [] def __init__(self, tags): self.tags = tags and a custom list field class TagsField(serializers.WritableField): """ ...
user1876508's user avatar
29 votes
5 answers
110k views

A list of tuples in Javascript [closed]

Let's say I receive a JSON-string containing information about people. Now I loop through all the JSON-objects and extract the name and age or each person. How would I store these as tuples in a list ...
Boris's user avatar
  • 8,753
27 votes
3 answers
48k views

Flutter Json Encode List

How to encode list to json? This is my class for Json. class Players{ List<Player> players; Players({this.players}); factory Players.fromJson(List<dynamic> parsedJson){ List&...
willy wijaya's user avatar
27 votes
3 answers
27k views

How to custom-sort a list of dict to use in json.dumps

I have a list similar to allsites = [ { 'A5': 'G', 'A10': 'G', 'site': 'example1.com', 'A1': 'G' }, { 'A5': 'R', 'A10': 'Y', '...
WoJ's user avatar
  • 28.5k
26 votes
8 answers
232k views

How to convert list data into json in java

I have a function which is returning Data as List in java class. Now as per my need, I have to convert it into Json Format. Below is my function code snippet: public static List<Product> ...
vikas's user avatar
  • 339
26 votes
2 answers
147k views

Python Parse JSON array

I'm trying to put together a small python script that can parse out array's out of a large data set. I'm looking to pull a few key:values from each object so that I can play with them later on in the ...
RomeNYRR's user avatar
  • 877
24 votes
3 answers
26k views

Jersey can produce List<T> but cannot Response.ok(List<T>).build()?

Jersey 1.6 can produce: @Path("/stock") public class StockResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Stock> get() { Stock stock = new Stock(); ...
yves amsellem's user avatar
21 votes
5 answers
144k views

How to put a List<class> into a JSONObject and then read that object?

I have a List<class> that I would like to convert into a json object and then traverse the data out of the json object. If this were just a List<String> I could just do something like: ...
Grammin's user avatar
  • 12k
20 votes
9 answers
94k views

How to Create JSONArray for a List<Class name>

I have a class called class Student { String name; String age; } I have a method that returns List object like public List<Student> getList(){ List<Student> li =new ArrayList(); ....
Navamani Samuel's user avatar
20 votes
2 answers
71k views

Create array of json objects using for loops

I'm attempting to extract values from an html and then convert them into a json array, and so far I have been able to get what I want, but only as separate strings: I did two for loops: for line in ...
geekiechic's user avatar
19 votes
3 answers
15k views

How can I access the nested data in this complex JSON, which includes another JSON document as one of the strings?

I have some JSON data like: { "status": "200", "msg": "", "data": { "time": "1515580011", "video_info": [ ...
aquatic7's user avatar
  • 615
18 votes
6 answers
71k views

Creating a list from JSON in Flutter

Following an online example I have the following code: _fetchData() async { setState(() { isLoading = true; }); final response = await http.get( "https://apiurl..."); ...
Ciprian's user avatar
  • 3,136
18 votes
2 answers
49k views

How to convert c# generic list to json using json.net?

I am converting my datatable to c# generic list. DataTable dt = mydata(); List<DataRow> list = dt.AsEnumerable().ToList(); Now how can i convert this list to json using json.net? Any ...
ACP's user avatar
  • 35.1k
17 votes
3 answers
162k views

How to add an element to a list?

From this.. data = json.loads(urlopen('someurl').read()) ...I will get: {'list': [{'a':'1'}]} I want to add {'b':'2'} into the list. Any idea how to do it?
doniyor's user avatar
  • 37.2k
15 votes
2 answers
49k views

Generating a json in a loop in python

I have some difficulties generating a specific JSON object in python. I need it to be in this format: [ {"id":0 , "attributeName_1":"value" , "attributeName_2&...
Below the Radar's user avatar
15 votes
1 answer
18k views

Use nlohmann json to unpack list of integers to a std::vector<int>

I'm using nlohman::json. It's awesome, but is there any way to unpack: { "my_list" : [1,2,3] } into a std:vector<int> ? I can't find any mention in the docs, and std::vector<...
P i's user avatar
  • 29.8k
14 votes
4 answers
23k views

Display JSON data on a page as a expandable/collapsible list

I need help with with displaying JSON data on a page like expandable/collapsible list. Here is a valid JSON I`ve made converting from XML with Python: JSON Data And to display it I`m usig this: &...
MilicaJ's user avatar
  • 141
14 votes
2 answers
67k views

Return Json from Generic List in Web API

I build my list like this: public static List<SearchFormula> SearchData(string searchString) { var searchResults = new List<SearchFormula>(); SqlDataReader drResults = ...
Brett Spencer's user avatar
13 votes
1 answer
53k views

C# How To return List<> As Json

I am having problem with Json and Lists I am trying to return a list of Chat Entity class but when i try to return it the compiler whines. I also tried to return IEnumerable<> but the same error ...
user2369105's user avatar
11 votes
4 answers
45k views

Using Python to extract dictionary keys within a list

I received a list when inputting the following URL - http://api.twitter.com/1/trends/44418.json The list contains multiple dictionaries, and I'm a bit confused with the list structure. I'm trying to ...
Alex Karpowitsch's user avatar
11 votes
5 answers
26k views

more pythonic way to format a JSON string from a list of tuples

Currently I'm doing this: def getJSONString(lst): join = "" rs = "{" for i in lst: rs += join + '"' + str(i[0]) + '":"' + str(i[1]) + '"' join = "," return rs + "}" ...
Charlie Skilbeck's user avatar
11 votes
5 answers
134k views

Parse JSON String into List<string>

string json = "{\"People\":[{\"FirstName\":\"Hans\",\"LastName\":\"Olo\"} {\"FirstName\":\"Jimmy\",\"LastName\":\"Crackedcorn\"}]}"; var obj = JObject.Parse(json); List&...
ChangeJar's user avatar
  • 163
11 votes
4 answers
18k views

how to parse complex json in flutter

I have trouble getting data from a complex json, below is the json in the request. { "results":{ "TotalRecordCount":"1", "Records":[ { ...
killuazoldayeck's user avatar
11 votes
4 answers
46k views

Read Json data from text file C#

I have a text file with below format data [ { "SponsorID": 1, "FirstBAID": 7395836 }, { "SponsorID": 2, "FirstBAID": 3509279, "SecondBAID": ...
Letoncse's user avatar
  • 722
11 votes
3 answers
36k views

Java List to JSON array using Jackson with UTF-8 encoding

Now I'm trying to convert Java List object to JSON array, and struggling to convert UTF-8 strings. I've tried all followings, but none of them works. Settings. response.setContentType("application/...
Mingoo's user avatar
  • 477
10 votes
4 answers
37k views

Remove duplicate JSON objects from list in python

I have a list of dict where a particular value is repeated multiple times, and I would like to remove the duplicate values. My list: te = [ { "Name": "Bala", "phone": "None" ...
Tony Roczz's user avatar
  • 2,378
10 votes
2 answers
35k views

C# serialize and deserialize json to txt file

I'm using NewtonSoft for handling json in my wpf application. I've got a customer that can be saved to a txt file (no database involved). I'm doing that like this: public int store(string[] ...
Jenssen's user avatar
  • 1,841
9 votes
2 answers
47k views

The JSON value could not be converted to System.Collections.Generic.List

I am trying to make a list of all items in the game using System.Text.Json; I am very new to using .json files I have tried doing this to test if it works: List<Item> AllItems = new ...
PrinceJKB's user avatar
  • 103
9 votes
1 answer
3k views

Lift Framework can't deserialize JSON data

I'm trying to deserialize JSON text using the Lift framework, and it doesn't appear that they support Seq trait (although List is supported). As an example... Some JSON data representing employees (...
shj's user avatar
  • 1,628
9 votes
1 answer
9k views

JSON deseralization to abstract list using DataContractJsonSerializer

I'm trying to deserialize a JSon file to an instance of a class that contains an abstract list. Serializing the instance to the Json works well (check the json file below). When deserializing I get a "...
noon's user avatar
  • 335
9 votes
2 answers
228 views

Convert redundant array to dict (or JSON)?

Suppose I have an array: [['a', 10, 1, 0.1], ['a', 10, 2, 0.2], ['a', 20, 2, 0.3], ['b', 10, 1, 0.4], ['b', 20, 2, 0.5]] And I want a dict (or JSON): { 'a': { 10: {1: 0.1, 2: 0.2}, ...
keisuke's user avatar
  • 2,233
9 votes
4 answers
6k views

jackson xml lists deserialization recognized as duplicate keys

I'm trying to convert xml into json using jackson-2.5.1 and jackson-dataformat-xml-2.5.1 The xml structure is received from web server and unknown, therefore I can't have java class to represent the ...
itaied's user avatar
  • 6,957
8 votes
1 answer
60k views

Deserializing JSON object into a C# list

I'm trying to deserialize a given JSON file in C# using a tutorial by Bill Reiss. For XML data in a non-list this method works pretty well, though I would like to deserialize a JSON file with the ...
user2282587's user avatar
8 votes
1 answer
24k views

How to read data from json on C#

I have the following json Object that I pass to my c# server [ { "ID": 1, "FirstName": "Jay", "LastName": "Smith" }, { "ID": 2, "FirstName": "Rich",...
EagleFox's user avatar
  • 1,367
8 votes
3 answers
5k views

Why should I take List<> instead of array in JSON deserialization ?

First of all let me tell you one thing that I am posting this question is just for eagerness and to increase my knowledge. Hope you can clear my doubts ! Now lets come to the point I got this ...
Chintan's user avatar
  • 2,788
7 votes
2 answers
14k views

How to create a list of the dictionaries in Golang?

I'm a newbie in Golang. I'm going to create a list of dictionaries that is resizable (this is not static) with append some dict to the list. Then I want to write it on a file, but I was confused. I ...
Benyamin Jafari's user avatar
7 votes
3 answers
17k views

Java - Object Mapper - JSON Array of Number to List<Long>

In my front end I send this JSON: "ids": [ 123421, 15643, 51243], "user": { "name": "John", "email": "[email protected]" } To my Spring Endpoint below: @PostMapping(value = "/sendToOficial") ...
WitnessTruth's user avatar
7 votes
1 answer
7k views

Using lift-json, is there an easy way to extract and traverse a list?

I think I may be missing something fundamental from the list-json xpath architecture. The smoothest way I've been able to extract and traverse a list is shown below. Can someone please show me a ...
Fred Haslam's user avatar
  • 8,993
7 votes
1 answer
17k views

Using python f-string in a json list of data

I need to push data to a website through their API and I'm trying to find a way to use F-string to pass the variable in the data list but couldn't find a way. Here's what I've tried so far: today = ...
locq's user avatar
  • 301
7 votes
2 answers
1k views

How to convert a dataframe into a nested list?

I have a dataframe that I want to convert to a nested list with a custom level of nesting. This is how I do it, but I'm sure there is a better way: data <- data.frame(city=c("A", "A", "B", "B"), ...
nachocab's user avatar
  • 13.9k
7 votes
2 answers
7k views

How to Use JSON Accumulate Method With List?

I am trying below code.... public String listToJsonString(String keyName, List<StyleAttribute> attrs) { JSONObject json = new JSONObject(); json.accumulate(keyName, attrs); ...
user avatar
7 votes
1 answer
1k views

Update Sharepoint 2013 using Python3

I am currently trying to update a Sharepoint 2013 list. This is the module that I am using using to accomplish that task. However, when I run the post task I receive the following error: "b'{"error"...
Francois Barnard's user avatar
6 votes
2 answers
20k views

Convert scala list to Json object

I want to convert a scala list of strings, List[String], to an Json object. For each string in my list I want to add it to my Json object. So that it would look like something like this: { "...
malmling's user avatar
  • 2,438
6 votes
2 answers
2k views

java/jackson - don't serialize wrapping class

When serializing a list of string with Jackson library, it provides correctly a JSON array of strings: <mapper>.writeValue(System.out, Arrays.asList("a", "b", "c")); [ "a", "b", "c" ] However,...
user avatar

1
2 3 4 5
46