Angular ngFor "Cannot convert object to primitive value" - json

i've just import a json file with some sample data and i would like to create a table of that. For the data i use an interface class OrderLineItems.ts, then i will import the file in the shopware Grid Component, which works well i guess. But when i just use console.log.
shopware-grid.component.ts
When i try to use the products property at the shopware-grid.component.html with ngFor i get the following convert Error.
shopware-grid.component.html
core.mjs:6362 ERROR TypeError: Cannot convert object to primitive value
at NgForOf.ngDoCheck (common.mjs:3200:87)
at callHook (core.mjs:2504:18)
at callHooks (core.mjs:2463:17)
at executeInitAndCheckHooks (core.mjs:2414:9)
at refreshView (core.mjs:11713:21)
at refreshComponent (core.mjs:12793:13)
at refreshChildComponents (core.mjs:11488:9)
at refreshView (core.mjs:11748:13)
at refreshComponent (core.mjs:12793:13)
at refreshChildComponents (core.mjs:11488:9)
GitHub Link

Related

how can I handle solana api get_transaction method error?

I want to get transaction details using Solana API with python. There are two documents for it.
1: https://docs.solana.com/developing/clients/jsonrpc-api#gettransaction
2: https://michaelhly.github.io/solana-py/rpc/api/#solana.rpc.api.Client.get_transaction
I used this code below
solana_client = Client("https://api.mainnet-beta.solana.com")
from solders.signature import Signature
sig = Signature.from_string("3NHUEPkc7a2mPkC51umAbLdNjrwoEaCXfdJ7BjHaEhYPchy5TtrCifbJqSujyZCNRuDKDfJvpN8osx9KvSWdwMp8")
solana_client.get_transaction(sig).value.block_time
and I got multiple errors
TypeError: Object of type Signature is not JSON serializable
TypeError: dict had unencodable value at keys: {params: because (list had unencodable value at index: [0: because (Object of type Signature is not JSON serializable)])}
TypeError: Could not encode to JSON
Any idea how can i handle this error?

Type '{}' is missing the following properties from type 'Datos[]': when instantiating list from JSON in Angular

I'm having problems to import JSON data into my angular application.
What I'm doing:
Import the json file into a variable:
import _datos from '../../../assets/data.json';
As specified in the answers of this question (How to import JSON File into a TypeScript file?), I'm using the typing.d.ts file in order to be able to read the information.
Declaring an interface in order to improve the readability of the code:
export interface Datos{
property1: String,
property2: String,
etc.
}
Declaring and instantiating the array with the json file imported:
datos: Datos[] = _datos;
What is expected
The variable "datos" should have the content of the JSON file as an array.
What actually happens
Type '{}' is missing the following properties from type 'Datos[]': length, pop, push, concat, and 26 more.ts(2740).
Further information
I've done it before with a smaller JSON file (this one has about 26 properties each object and +100k elements) and worked fine. However, this one is failing and I don't really know why.
Okay it was a very simple mistake:
One of the 26 properties in the JSON file was not written properly. In order for this to work, it is needed that the properties in the JSON file and the properties in the interface match.
The JSON file is something like this:
[
{
"organo_de_contratacion": "Consorcio de Transportes de la Bahía de Cádiz",
"estado_de_la_licitacion**:**": "Resuelta",
...
So that the : slipped before the ending of the property and missmatched the interface property.
To avoid the error:
Type '{}' is missing the following properties from type ...
Ensure that the object _datos is being assigned is an array of objects of type Datos.
This occurs when assigning an object { .. } to an array of objects [ {}, .. ]
Your variable that holds the imported array needs to be declared as follows:
_datos: Datos[] = [];
Then import your JSON file data into _datos.
I would suggest debugging the value of _datos before it is assigned to the datos variable.

Circular Structure to JSON, UI Runtime Error TypeError

I am getting an error when trying to parse and stringify some JSON data.
On this line:
this.copyOfColumns = JSON.parse(JSON.stringify(Object.assign([], this.columns)));
Here is the entire #Input (using Angular 4):
#Input()
set gridColumns(gridColumnsArr: Array<object>) {
console.log('gridColumnsArr');
console.log(gridColumnsArr);
this.columns = this.sortActiveAndInactiveColumns(gridColumnsArr);
console.log('this.columns');
console.log(this.columns);
this.copyOfColumns = JSON.parse(JSON.stringify(Object.assign([], this.columns)));
console.log('this.copyOfColumns');
console.log(this.copyOfColumns);
}
Here is the data logged to the console (this.columns)...and the error(s) following:
I assume you want to deep copy the array by using JSON.parse(JSON.stringify()). Apparently your data structure has circular references which fails the JSON.stringify().
Either you should sanitize your data to not contain ciruclar references or you could try using a library like flatted

TypeError: the JSON object must be str, not 'list'

Hi i want to make JSON readable by using loads and dumps, but i encountered this error
"TypeError: the JSON object must be str, not 'list'"
Here is my code:
parsedCoin = json.loads(coin)
print(json.dumps(parsedCoin, indent=4, sort_keys=True))
how i can solve this problem?
json.loads expects a string. json.dumps(coin) will give you a string version of coin.

org.openx.data.jsonserde.json.JSONObject cannot be cast to org.openx.data.jsonserde.json.JSONArray

I am trying to read json file from hive.
I an using JsonSerde api to load json but getting an error
... 16 more
Caused by: java.lang.ClassCastException: org.openx.data.jsonserde.json.JSONObject cannot be cast to org.openx.data.jsonserde.json.JSONArray
at org.openx.data.jsonserde.objectinspector.JsonListObjectInspector.getList(JsonListObjectInspector.java:38)
at org.apache.hadoop.hive.serde2.SerDeUtils.buildJSONString(SerDeUtils.java:297)
at org.apache.hadoop.hive.serde2.SerDeUtils.getJSONString(SerDeUtils.java:197)
at org.apache.hadoop.hive.serde2.DelimitedJSONSerDe.serializeField(DelimitedJSONSerDe.java:60)
at org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe.doSerialize(LazySimpleSerDe.java:422)
at org.apache.hadoop.hive.serde2.AbstractEncodingAwareSerDe.serialize(AbstractEncodingAwareSerDe.java:50)
at org.apache.hadoop.hive.ql.exec.DefaultFetchFormatter.convert(DefaultFetchFormatter.java:71)
at org.apache.hadoop.hive.ql.exec.DefaultFetchFormatter.convert(DefaultFetchFormatter.java:40)
at org.apache.hadoop.hive.ql.exec.ListSinkOperator.processOp(ListSinkOperator.java:87)
Does any one have any idea about how to fix this?
You are trying to process Array, but you are given Object.
In Json:
Object is: {...}
Array is: [...]
Examples:
Accessing array:
myArray[0]
Accessing object: myObject.myField