New answers tagged json
Best practices
0 votes
0 replies
0 views
Best way to go from JSON to bash variables
Thank you so much for this extra, in-depth, example. POSIX-compatible/"pure sh" code is a bit above my pay grade and level of experience. I never had to do anything in pure POSIX-sh. I Just ...
2 votes
Accepted
How can I iterate through a JSON file with PHP and access the second element of the file?
You need to add a key to the loop, which you can then use to reference the next element. However, you'll run into an issue at the end of the loop, but that's also easily checked. foreach ($path->...
Best practices
0 votes
0 replies
0 views
Best way to go from JSON to bash variables
See my latest update, I think this one is very versatile reusable and safe finally providing a custom mapping of json property paths into specific shell variables.
Best practices
1 vote
0 replies
0 views
Best way to go from JSON to bash variables
POSIX-sh is the next step and an occasion to feel the limits of this language with a very practical exemple: #!/bin/sh # This script demonstrates how to safely parse JSON data # into shell variables ...
Best practices
1 vote
0 replies
0 views
Best way to go from JSON to bash variables
Thanks, interesting solution. Looks complex, but given that bash was never meant to be used for ~~returning~~ printing complex data like this it is either an effort of having to present such data in a ...
Best practices
1 vote
0 replies
0 views
Best way to go from JSON to bash variables
You still need to filter output to make an associative array declaration #!/usr/bin/env bash json='{ "data": { "foo": "blah", "bar": "blergh", ...
Best practices
1 vote
0 replies
0 views
Best way to go from JSON to bash variables
Thank you. If I want to turn my code into a bash function, the I stdout's this: # Debug print data printf '%s\n' "$data" and then I read output like this: data=$(my_func) declare -A dict=&...
Best practices
2 votes
0 replies
0 views
Best way to go from JSON to bash variables
jq provides all the tooling to safely generate shell-safe values with its @sh filter. With the JSON data object, it can map each keys and values and transform this into a Bash associative array ...
Advice
0 votes
0 replies
0 views
Does JS usage affect my website's security
The reply might be AI-generated, but it is bang-on: don't store sensitive information in JavaScript. Anyone can see it. In fact, don't store sensitive information in LocalStorage, either. An HTTP-only ...
-1 votes
Getting error on Wordpress: Fatal error: Uncaught Error: Call to undefined function json_decode()
In addition to the other answers: If this is for a plugin or similar, you might want to check if the function json_decode is defined before calling it: if(!function_exists("json_decode"))...
0 votes
How to remove null values generated by a jackson custom serializer?
This needs two things now. The member needs to have the annotation @JsonInclude(NON_EMPTY) and the serializer needs to implement: public boolean isEmpty( final SerializerProvider provider, ...
Advice
0 votes
0 replies
0 views
Does JS usage affect my website's security
Interested to hear how you know it’s a common misunderstanding - best not to dump AI generated advice here.
Advice
1 vote
0 replies
0 views
Does JS usage affect my website's security
Storing secrets in Firebase Secrets is a good start, but there is a common misunderstanding: using secrets on the server-side is secure, but referencing them in your frontend code is not. If your ...
Advice
0 votes
0 replies
0 views
Does JS usage affect my website's security
My sensitive informations are stored in firebase cloud, using firebase secrets.
Advice
2 votes
0 replies
0 views
Does JS usage affect my website's security
If you're doing your API calls directly from the browser using frontend JavaScript, you have a major security hole. Anything in your frontend JS is public. If your API keys are in your code, anyone ...
Advice
0 votes
0 replies
0 views
Why is there no `orient=table` option for `pandas.DataFrame.to_dict`?
This is really helpful, thank you! I thought that because some to_dict options give you a bit of metadata (i.e. tight), it wouldn't be much more to add table; but I suppose the additional metadata is ...
1 vote
How can I send a POST request with a CSRF Token and a JSON body to a Django endpoint?
I would recommend switching to a REST API library for production APIs, especially for mobile apps, such as django-rest-framework since they simplify authentication and already do a good bit of the ...
2 votes
Python json normalization - nested structure
Using record_path='reports' and meta=['_id'] then rearrange and rename columns to get the desired dataframe. This approach also works if you have multiple (a list of) reports in the json data. import ...
3 votes
Python json normalization - nested structure
Using record_path=['reports'] does roughly what you want. The only exception is that it doesn't capture the report_id column. You can add a line to provide that column. import pandas as pd import json ...
Advice
0 votes
0 replies
0 views
0 votes
JSON cannot be parsed as the type Int32
I don't know how you expect to make any forward progress under those constraints. You essentially said you did a python assignment of n = 2_412_053_228_149_000_107, you serialized it to JSON, and then ...
Best practices
0 votes
0 replies
0 views
How to sort my functions in python code with regards to efficiency
For efficiency, file structure usually doesn’t affect performance much in Python. It’s better to organize code for readability and maintainability. Split code into multiple files (modules) when they ...
-1 votes
Moshi 1.9.x Cannot serialize Kotlin type
https://www.baeldung.com/kotlin/sealed-class-serialization Full example reproduced, below. import com.squareup.moshi.Moshi import com.squareup.moshi.adapters.PolymorphicJsonAdapterFactory import com....
Best practices
0 votes
0 replies
0 views
How to sort my functions in python code with regards to efficiency
Assuming this is any more than a trivial project then it's likely to be easier to maintain and understand the code (and source-control it) if you have it split across different files for different ...
Best practices
3 votes
0 replies
0 views
How to sort my functions in python code with regards to efficiency
Whether you have the code spread over different files or not, this doesn't impact efficiency, since the code is parsed into bytecode, where the original files don't play a role anymore. Concerning ...
Best practices
1 vote
0 replies
0 views
How to sort my functions in python code with regards to efficiency
Remove the global variables: they will make it harder to test your code, and they will be a source of bugs if you're using any sort of concurrency model (threading, multiprocessing, and asyncio will ...
Best practices
1 vote
0 replies
0 views
How to sort my functions in python code with regards to efficiency
do whatever you like. But all in one file can be unreadable for people.
0 votes
Excel VBA - parse JSON string and set cell values based on key:values
This code can process the sample data Sub processjson() inpstring = Range("H1") i = 1 colcount = 1 rowcnt = 1 Do While InStr(i, inpstring, ":") <> 0 If colcount = 5 Then ...
-1 votes
Validate JSON against XML Schema (XSD)
XSD (XML Schema) is designed to validate XML, not JSON directly. So validating JSON against an XSD usually requires converting the JSON structure into XML first. Typical approach: 1. Convert JSON → ...
Advice
0 votes
0 replies
0 views
dict of count JSON
json.dump(data, json_file, indent=2) must be inside of with open ('health_records.json', 'w') as json_file: context
0 votes
Optimizing Exact Filtered Pagination Count (COUNT(*)) on MySQL with Dynamic JSON Filters in Spring Boot API
Since you need to get at various parts of the JSON, you should make columns for those parts in the table. Extract them when receiving the data. Also, do cononical transformations as desired (remove ...
Advice
0 votes
0 replies
0 views
Advice
0 votes
0 replies
0 views
dict of count JSON
by the way: if you would add some example data in JSON and expected result then we could use it to create real code.
Advice
0 votes
0 replies
0 views
dict of count JSON
Eventually you could load it to pandas.DataFrame() and then you could do avg_bmi = df['bmi'].mean()
Advice
0 votes
0 replies
0 views
Advice
0 votes
0 replies
0 views
dict of count JSON
in get_statistics() you have to load file (with json.load) and use for-loop to work with every dictionary on the list. And finally it may need to use return barbie.
Advice
1 vote
0 replies
0 views
dict of count JSON
fixed the issue :) is there anything else i could do better. My main problem is that i have trouble making get_statistics automatic
Advice
1 vote
0 replies
0 views
0 votes
Download a JSON text file in the webpage using only JavaScript/jQuery
here's what worked for me I found it on https://codesandbox.io/p/sandbox/download-json-file-with-js-p9t1z?file=%2Findex.html%3A40%2C11 <button onclick="onDownload()">Download</...
Best practices
0 votes
0 replies
0 views
Best practices for structuring LLM prompts to extract multi-dimensional emotional metadata from dream narratives?
For extracting structured psychological metadata from subjective text like dream narratives, a Schema-First + Few-Shotapproach works best. Here's what I'd recommend: 1. Define your schema explicitly ...
Best practices
0 votes
0 replies
0 views
Best practices
0 votes
0 replies
0 views
mtgjson.com usage recommendations
MTG = Magic the gathering. Collectable card game. Scryfall url: Scryfall.com Mtgjson url: https://mtgjson.com/
Best practices
0 votes
0 replies
0 views
0 votes
How to create an output json file from Foundry Pipeline Builder?
you have to transform the data first into json, then write the output as json in transform you can first create struct column ()and then convert it into Json string these are build in functions ...
0 votes
AWS Stepfunctions: Use a JSON value as part of JSONPath?
Most JSONPath libraries don't allow dynamic property names. If the StepFunction did, then $[1].CurrentHashes[$[0].ChallengeData.Answer] would work with your JSON. What can work is if you change your ...
1 vote
Remove JSON object from JSONArray - Jettison
This seems to be an oversight by the library. I've filed a bug here: https://github.com/jettison-json/jettison/issues/113 I've filed a patch here: https://github.com/jettison-json/jettison/pull/...
Best practices
0 votes
0 replies
0 views
Best practices for structuring LLM prompts to extract multi-dimensional emotional metadata from dream narratives?
Always use the same prompt structure, as it was used in training that LLM model.
1 vote
Extend configuration with custom settings loaded from file
One of the node-config maintainers here. node-config generally works better for sorting out startup-time configuration for an app. For the use-case you are looking at here, there are two options I ...
0 votes
CodeIgniter query builder script to SELECT rows WHERE a JSON column contains a property with a qualifying value
JSON_CONTAINS() is a better suited way to parse the flat JSON array of double-quoted integers and determine row qualification. public function getChildProduct(int $parent_id, ?int $limit = null, ?int $...
0 votes
SELECT rows WHERE a JSON column contains a specific property value using CodeIgniter's query builder
It's a bit cumbersome to try to shoehorn JSON accessing syntax into a WHERE clause building method because the ->> fools with CodeIgniter's parsing of the expression. Ultimately, to keep using ...
Top 50 recent answers are included
Related Tags
json × 360526javascript × 78494
php × 40964
java × 39236
jquery × 36882
python × 34032
c# × 27209
arrays × 25492
android × 25294
ajax × 18573
node.js × 11721
html × 11500
angularjs × 9458
rest × 9295
ios × 9028
mysql × 8889
jackson × 8878
parsing × 8647
swift × 8362
json.net × 7371
serialization × 6925
gson × 6007
reactjs × 5772
sql × 5131
ruby-on-rails × 5104