Loop through map and push to a new object group if items have matching values

I have the following data structure in its simplest form: items: [ { id: 1, account: ‘acct_101’ }, { id: 2, account: ‘acct_52’ }, { id: 3, account: ‘acct_33’ }, { id: 4, account: ‘acct_101’ }, { id: 5, account: ‘acct_101’ }, ] I would like to separate the items into groups based on their… Read More Loop through map and push to a new object group if items have matching values

Decoding JSON in PHP can't access the first key

I have a PHP script which successfully decodes a JSON string into a PHP object using: $amount_detail = json_decode($tuitionfee->amount_detail); when I print it out, this is what I get stdClass Object ( [1] => stdClass Object ( [amount] => 0 [date] => 2023-01-08 [amount_discount] => 55200 [amount_fine] => 0 [description] => [collected_by] => Super Admin(356)… Read More Decoding JSON in PHP can't access the first key

Can't map imported JSON data: TypeError thrown

Here’s sample data stored in data.json file: [ {"id": 23, "name": "Good!", "state": "OK"}, {"id": 24, "name": "Not good…", "state": "Fail"}, {"id": 26, "name": "Oh…", "state": "OK"}, {"id": 27, "name": "What?", "state": "Fail"} ] And this script tries to map the data: import * as data from ‘./data.json’ let jsonData = data console.log(jsonData) jsonData =… Read More Can't map imported JSON data: TypeError thrown

Advice needed to parse this JSON in .NET

Given the following JSON samples, what is the best way to parse this in c# .NET? {"data":{"5":{"isDeleted":"false","day":"THU"}},"action":"edit"} {"data":{"7":{"isDeleted":"false","name":"alex"}},"action":"edit"} {"data":{"90":{"isDeleted":"true","job":"software"}},"action":"edit"} I have looked into JSON serializing into an object but because the data could be different each time i can’t map it directly to a model. >Solution : So the model for this could be public… Read More Advice needed to parse this JSON in .NET

JSON returned from Response.json() appears to be invalid?

Checking the JSON output of my application on https://jsonlint.com/ indicates that the JSON is invalid… But I cannot fathom how it’s invalid. The JSON in question: { records: [{ id: 70, whse: ’00’, partNo: ‘100E’, description: ‘1" EMT CONDUIT (BUNDLE QTY. 1000FT)’, }], start: 0, limit: 10, count: 1 } I’ve tried changing the type… Read More JSON returned from Response.json() appears to be invalid?

Deserialize JSON Exception

I’m having a problem deserializing a json file to an object, it’s returning a JSON exception, here’s my code: class Program { static void Main(string[] args) { LoadJson(filePath); } public static void LoadJson(string filePath) { using (StreamReader r = new StreamReader(filePath)) { string json = r.ReadToEnd(); List<Rootobject> items = JsonConvert.DeserializeObject<List<Rootobject>>(json); } } } public class… Read More Deserialize JSON Exception

Why doesn't PHP function json_decode() work on strings formatted in double quotes?

Why does json_decode() function in php return nothing in the code below? <?php $str = "[[‘123’],[‘123’]]"; print_r(json_decode($str)); ?> Result: Literally white screen of death. Cause Im running this on browser. Note! If I change the string that is stored inside of variable $str from having double quotes, to having single quotes the json_decode() works as… Read More Why doesn't PHP function json_decode() work on strings formatted in double quotes?

How to import multiple json file into mysql database at same time?

I have a database , that cantain about 10 column. each column should get values from seprate json file. how i can do that at same time? for example : column1 —— file1.json column2 —— file2.json column3 —— file3.json column4 —— file4.json my php code is something like this: <?php //connect to mysql db $con… Read More How to import multiple json file into mysql database at same time?