Questions tagged [json]

91041 questions
1

votes
3

answer
2.7k

Views

Python how convert single quotes to double quotes to format as json string

I have a file where on each line I have text like this (representing cast of a film): [{'cast_id': 23, 'character': 'Roger 'Verbal' Kint', 'credit_id': '52fe4260c3a36847f8019af7', 'gender': 2, 'id': 1979, 'name': 'Kevin Spacey', 'order': 5, 'profile_path': '/x7wF050iuCASefLLG75s2uDPFUu.jpg'}, {'cast...
revy
0

votes
4

answer
428

Views

Explain the functionality of JSON

I think it is better to understand why I have so many problems with JSON that I explain you what my goal is: I work with Googles App Engine. There I want to store data. The data looks like user - username question - question date1 - date1 date2 - date2 An Android App have the 'simple' function to: S...
StefMa
1

votes
3

answer
137

Views

JSON to Python objects

I am deliberating about how to transfer the complex information from a JSON API response to (several) Python objects. I have included the (lengthy) model response below. Note that some values are not always included in the response, and some values are a list of dictionaries. Is there an 'easy' way...
Dave
1

votes
2

answer
1.4k

Views

Showing json field in Django admin

I have an Django model as follows: class BodyHeight(models.Model): seats = models.ForeignKey(to=Seats) name = models.CharField(max_length=127, null=True, blank=True) key = models.CharField(max_length=100, null=True) data = models.TextField(null=True, blank=True) class Meta: verbose_name_plural = 'Bo...
Boky
1

votes
1

answer
57

Views

How to index nested array

How to index (N1QL query in Couchbase) above document to speed up searching by SerialNumber field in nested array (doc => groups => items => item.SerialNumber)? Sample: { 'Id': '0012ed6e-41af-4e45-b53f-bac3b2eb0b82', 'Machine': 'Machine2', 'Groups': [ { 'Id': '0fed9b14-fa38-e511-893a-0011256...
Michał Zych
1

votes
2

answer
376

Views

Dynamically return fields from a web method

I have a WebAPI service where I would like to allow users to specify which fields they'd like returned. For example, say I have the following Person class: public class Person { public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } } and that ca...
Phillip Copley
1

votes
2

answer
2.5k

Views

How to render JSON response as dropdown list in React

I'm currently trying to take some JSON data that I've received from an API and put that into a dropdown in a very simple React application. This is my DropDown component thus far: import React from 'react'; var values; fetch('http://localhost:8080/values') .then(function(res) { return res.json(); })...
HomerPlata
1

votes
4

answer
87

Views

How to ouput desired data from a key in JSON if there are multiple keys

I want to output data of the lyrics_body key from the following URL.API Link But the JSON text on that URL is like that following. { 'message': { 'header': { 'status_code': 200, 'execute_time': 0.0047609806060791 }, 'body': { 'lyrics': { 'lyrics_id': 16894378, 'can_edit': 0, 'locked': 0, 'published_...
Nirzak
-1

votes
0

answer
11

Views

Fetch JSON data based on email using PHP

HI there What I want is to fetch the User Data based on the email ID From The JSON File. the Json Data is in this Format . [ { 'id': 1, 'name': 'Leanne Graham', 'username': 'Bret', 'email': '[email protected]', 'address': { 'street': 'Kulas Light', 'suite': 'Apt. 556', 'city': 'Gwenborough', 'zipco...
Abnit Chauhan
1

votes
1

answer
163

Views

Capturing JSON data from intermediate events using Selenium

Below I have setup a script which simply executes a search on a website. The goal is to capture JSON data utilizing Selenium from an event that is fired from an intermediate script, namely the POST request to 'https://www.botoxcosmetic.com/sc/api/findclinic/FindSpecialists' as seen in the included i...
ikemblem
1

votes
3

answer
402

Views

how to parse the json data and display it in grid view

I am working on a project in that i want to show the JSON data in grid view. I tried volley to get data but the data is not displayed in grid view. Below is my Json api { 'status': 200, 'msg': 'success', 'data': [ { 'category_name': 'ELECTRONICS', 'category_description': 'ELECTRONICS Items', 'categ...
Mercedes
1

votes
2

answer
301

Views

Is it good practice to store JSON object in cookie? [closed]

I have following object. position = { latitude: 19.067863700000004, longitude: 72.9991898, pincode: 400701 } I want to store value of latitude, longitude and pincode in cookie. I know three ways. i) store entire position object in cookie.(which is not recommended according to this) var pos = JSON.st...
yajiv
1

votes
1

answer
637

Views

Pentaho DI - JSON Nested File Output

I have a requirement where I need to fetch records from multiple tables. The primary table is having one-to-many relationship to other tables. My data source is Oracle DB. Oracle db is having the specified tables. One called Student other one is Subjects. For sample, I have a Student Table where 'S...
1

votes
2

answer
523

Views

Azure CloudBlobStream serialization (with Json.NET)

I have a little problem. My environment is a console app in .NET Core 2.1. Look at the this code: private static void Main(string[] args) { try { Console.WriteLine($'Test starts: {DateTime.Now.ToString('o')}'); string connectionString = '[My connection string]'; string containerName = 'mycontainer';...
Attilio Gelosa
1

votes
3

answer
72

Views

C# serialize json to class

This is my json : '{\'sctoken\':\'a50395d5-571983f3-b394-4c6f-a26a-f95ae125fad6\',\'tms\':[{\'name\':\'ELTE MapCenterCache\',\'url\':\'http://cache2.smok.net.pl/cache_2015/element?s=%zoom%&x=%x%&y=%y%\'},{\'name\':\'OSM Mapnik\',\'url\':\'http://tile.openstreetmap.org/%zoom%/%x%/%y%.png\'},{\'name\...
kpokrywja
1

votes
1

answer
1.8k

Views

Parse JSON Array in Scala

I have this jsArray (json Array) and I am using import play.api.libs.json._ library. [{”device”:”Samsung S8”,”android”:true}, {”device”:”iPhone 8”,”android”:false}, {”device”:”MacBook Air Pro”,”android”:false}, {”device”:”Dell XPS”,”android”:false}] I...
1

votes
1

answer
429

Views

Fetch : status 302 in Edge 17

I'm using js fetch API to retreive datas from JSON. It's working fine (even in IE 11), except in Edge 17 i get 302, the response header are : Content-length : 0 Content-type: text/plain; charset=utf-8 Location: http://local.mysite.com/xxx My local website is on a Mac, i'm using BrowserSync to make i...
Julien CHAZAL
1

votes
1

answer
697

Views

How to go on about receiving JSON array in flutter and parsing it?

I am trying to get a JSON array from a webservice URL and parse it in JSON. The thing is the tutorial I was following shows receving one JSOn obj and parsing it but I need to know how to receive a JSON array and parse it. Below is the code I am working on, I am stuck. Model class Fact { int id; int...
defiant
1

votes
2

answer
45

Views

How to store object in localStorage

I have the following code: localStorage.setItem('ActiveDataOfpModel', iHandle.find('ul li.pModel.active')); When i check 'ActiveDataOfpModel' value in console i get '[object Object]'. How can i store the actual object in 'ActiveDataOfpModel' and retrieve its properties. i.e. i want to do the followi...
Waleed Naveed
1

votes
1

answer
598

Views

Flutter parsing json with DateTime from Golang RFC3339: FormatException: Invalid date format

When trying to read json files generated with golangs json package in Dart / Flutter I noticed that parsing dates produce an error: FormatException: Invalid date format An example is the following json generated on the Go server: { ... 'dateCreated': '2018-09-29T19:51:57.4139787-07:00', ... } I am u...
Oswin Noetzelmann
1

votes
1

answer
42

Views

How to Append image using Json

I am creating an e-commerce site. i ran into the problem of displaying image on home page. all relevant data have displayed success. the only image couldn't be displayed.I didn't get any errors while checking the console. what i tried so far i attached below. Json **$('#Products').append('
creative one2018
1

votes
2

answer
355

Views

Use jq to parse json into environment variable format

I would like to below code to output KNOCK_KNOCK='Who is there?' TEST_FILE='{ 'KNOCK_KNOCK': 'Who is there?' }' for s in $(echo $TEST_FILE | jq -r 'to_entries|map(\'\ (.key)=\(.value|tostring)\')|.[]' ); do echo $s done I got the loop from this post: Exporting JSON to environment variables and cann...
George R Malary
1

votes
2

answer
163

Views

How to add item to json object ruby on rails?

I want to join items from 2 tables. There output: 'costs':[ { 'id':2, 'cost_name':'rent office', 'user_id':2, 'fix':true, 'amount':300300, 'created_at':'2018-11-05T18:36:19.108+06:00', 'updated_at':'2018-11-05T18:36:19.108+06:00' }, { 'id':3, 'cost_name':'new computer', 'user_id':2, 'fix':fals...
Arkhatinho
1

votes
2

answer
887

Views

Swift - “Expected to decode Array<Any> but found a dictionary instead.”

I am having a lot of trouble trying to decode this JSON with Swift 4.2: { token = a3253e6ade9b5c7fd99673938bb28b3e; user = { 'about_me' = Admin; address = ''; 'banner_path' = 'http://members.sharjahcd.ae/images/000/000/008/1540737652129.jpg?1541043871'; company = ''; description = ''; email = 'a...
Vignesh
1

votes
4

answer
819

Views

MongoDB regex string startswith and endswith [duplicate]

This question already has an answer here: Regex matching beginning AND end strings 4 answers Regular Expression to find string starts with letter and ends with slash / 3 answers So i have something that looks like this db.usuarios.insert ( [ { 'nome' : 'neymala', 'idade' : 40, 'status' : 'solteir...
user56130
1

votes
1

answer
21

Views

How to access nested JSON object in Python DataFrame

I have a JSON response that I am converting to a DataFrame in Python. JSON response: [ { 'id': 123456, 'first_name': 'John', 'last_name': 'Doe', 'fields': [ { 'title': 'ABC', 'value': '123' }, { 'title': 'DEF', 'value': '456' } ] } ] When I parse this JSON to a DataFrame, the columns appear as id, f...
Matt
0

votes
1

answer
14

Views

read json file, and print key, values using python

I want a conditional loop which should read json file, and print 'postId' based on 'user_name' matches an item in the list. I tried these baby steps to see, but it did not work Python version: 2.7.5 OS: Linux here's python script: import sys import re import json my_list = ['windows-super-user','l...
itgeek
0

votes
0

answer
21

Views

How to display data from this API function?

I am completely inexperienced with HTML and js development, but I'm currently working on a project where I take an API from a site, which contains GPS data, and display it on my webpage. I'm using a function from jQuery to achieve this. (Context: Inside an html file, this code is in ) $.getJSON('lin...
Kevin Ma
0

votes
2

answer
13

Views

Iterate through a groupby array of json

I have an array of JSON object as follows var array = [{'id':'1','value': '13'},{'id':'2','value': '23'},{'id':'1','value': '33'},{'id':'3','value': '13'}] Then I grouped the json array according to the id as follows var groupArray = {'1':[{'id':'1','value': '13'},{'id':'1','value': '33'}], '2': [{'...
tharindu
1

votes
0

answer
23

Views

How to detect duplicates in large json file using PySpark HashPartitioner

I have a large json file with over 20GB of json-structured metadata. It contains simple user metadata across some application, and I would like to sift through it to detect duplicates. Here is an example of how the data looks like: {'created': '2015-08-04', 'created_at': '2010-03-15', 'username': 'k...
John Lexus
-1

votes
3

answer
23

Views

Spark - Map flat dataframe to a configurable nested json schema

I have a flat dataframe with 5-6 columns. I want to nest them and convert it into a nested dataframe so that I can then write it to parquet format. However, I don't want to use case classes as I am trying to keep the code as configurable as possible. I'm stuck with this part and need some help. My...
devnong
1

votes
3

answer
223

Views

Spring default consumes and produces

I'm writing a servlet that will use a bunch of RestControllers to provide functionality. All of that will use JSON almost exclusively, so I would like a compact way to say: Unless specified otherwise, consume and produce MediaType.APPLICATION_JSON_VALUE for everything. I thought I found a nice solut...
Senshi
1

votes
2

answer
91

Views

Python JSON decoder error with unicode characters in request content

Using requests library to execute http GET that return JSON response i'm getting this error when response string contains unicode char: json.decoder.JSONDecodeError: Invalid control character at: line 1 column 20 (char 19) Execute same http request with Postman the json output is: { 'value': 'VILLE...
orion91
1

votes
3

answer
114

Views

How to iterate a JSON array in bash from jq

Background I want to be able to pass a json file to WP CLI, to iteratively create posts. So I thought I could create a JSON file: [ { 'post_type': 'post', 'post_title': 'Test', 'post_content': '[leaflet-map][leaflet-marker]', 'post_status': 'publish' }, { 'post_type': 'post', 'post_title': 'Number 2...
bozdoz
1

votes
2

answer
44

Views

Azure Transform XML to JSON

I'm trying to transform the following XML into JSON using Azure liquid mapping to find the session ID. 0 No error A VALUE I'm trying to use this liquid file to convert the XML to find the sessionID in JSON. { 'Session': '{{content.soap:Envelope.soap:Body.LogInResponse.SessionID}}' } This just retur...
Watsyyy
1

votes
2

answer
81

Views

JSON string from server side not coming properly using ajax jquery

What I am doing is, i am getting data from server side using mvc. The data is properly coming in return part. But when I m debugging in the client side, I am only getting the parameter value as [. Below is the JSON response which I am getting. [{'VENDORNAME':'ABC','VENDORCODE':'1234'},{'VENDORNAME':...
B N
1

votes
3

answer
72

Views

JQ Select Objects Where Inner Key Exists

I am trying to select credential objects only if key credhub-ref exist within them from the following JSON: { 'total_results': 23, 'total_pages': 1, 'prev_url': null, 'next_url': null, 'resources': [ { 'entity': { 'credentials': {}, 'binding_options': {}, 'gateway_data': null, 'gateway_name': '', 's...
Radford
1

votes
3

answer
50

Views

How to work around Gson serialization giving different results when using generic wildcards?

Consider this example: static class BaseBean { String baseField = 'base'; } static class ChildBean extends BaseBean { String childField = 'child'; } static class BaseBeanHolder { List
GhostCat
1

votes
2

answer
55

Views

Typescript - Why does this recursive function skips some numbers?

From the server, I receive this JSON object. It represents an organigram of a company and the associated departments. I need to be able to choose a company, and with the ID of the company, I need to pass to an array of numbers the ID's of the associated departments. For that, I've created this recu...
LuisMorais
1

votes
2

answer
53

Views

Performance difference between lodash “get” and “if else” clauses

Let's say you have a typescript object, where any element can be undefined. If you want to access a heavily nested component, you have to do a lot of comparisons against undefined. I wanted to compare two ways of doing this in terms of performance: regular if-else comparisons and the lodash function...
enanone

View additional questions