Comments (6)
Thank you for your last remark, because it is most probably that the package was not updated inside the docker container that is running the application.
Now the problem is solved and it works perfectly. So thank you for the update.
from react-admin-json-view.
Hi @fbigand thanks for reporting this bug.
It should be fixed in this new release: https://github.com/MrHertal/react-admin-json-view/releases/tag/v1.0.4
from react-admin-json-view.
Thank you for your response!
I installed the new release (1.0.4), but unfortunately the problem is not solved on my side. I tested with both nested object and nested array, but none of them work (I don't know if they are handled differently).
I used this object for the test:
{
...
"content": {
"test_array": [
1,
2,
3,
4
],
"test_object": {
"test": "test"
}
}
}
And I called JsonField like this inside my Show view:
...
<Tab label="Content">
<JsonField source="content.test_array" />
<JsonField source="content.test_object" />
</Tab>
...
Both of them render an empty json.
from react-admin-json-view.
Thanks for your response.
It would be interesting to know what your content
field looks like after react-admin gets the data.
Could you show the log of the record at this point? You can use a function field like this:
import { FunctionField } from 'react-admin';
<FunctionField
label="Test"
render={(record) => {
console.log(record);
return <JsonField source="content" record={record} />;
}}
/>
I would like to know if your content field is a string like this:
content: "{"test_array":[1,2,3,4],"test_object":{"test":"test"}}"
Or if it is an already parsed nested object like this:
content:
test_array: Array(4)
0: 1
1: 2
2: 3
3: 4
length: 4
__proto__: Array(0)
test_object:
test: "test"
__proto__: Object
__proto__: Object
from react-admin-json-view.
The console.log displays the record that wraps the "content" attribute, and it is displayed as Javascript object.
{…}
content: {…}
test_array: (5) […]
0: 0
1: 1
2: 2
3: 3
4: 4
length: 5
<prototype>: Array []
test_object: {…}
test: "test"
<prototype>: Object { … }
<prototype>: Object { … }
id: 12
title: "Some title"
<prototype>: Object { … }
from react-admin-json-view.
This is weird, I could not reproduce. Here is what I tried:
import { SimpleShowLayout, FunctionField } from "react-admin-json-view";
import { JsonField } from "react-admin-json-view";
<SimpleShowLayout>
<FunctionField
label="content.test_array"
render={(record) => {
const flowParams = JSON.parse(record.flowParams);
console.log(flowParams);
return (
<JsonField
source="content.test_array"
record={{ ...record, content: flowParams }}
/>
);
}}
/>
<FunctionField
label="content.test_object"
render={(record) => {
const flowParams = JSON.parse(record.flowParams);
console.log(flowParams);
return (
<JsonField
source="content.test_object"
record={{ ...record, content: flowParams }}
/>
);
}}
/>
</SimpleShowLayout>
On my project, flowParams
field is a JSON string that has this value: {"test_array":[1,2,3,4],"test_object":{"test":"test"}}
.
In order to be as close as possible to your case, I parsed this value and set the result to record.content
.
console.log(flowParams);
is printing:
{test_array: Array(4), test_object: {…}}
test_array: (4) [1, 2, 3, 4]
test_object: {test: "test"}
__proto__: Object
As a result, I got this:
Can you check the difference with your code?
Did you restart your project after upgrading this package? (sorry I have to make sure 🙂)
from react-admin-json-view.
Related Issues (13)
- Add a screenshot and a license HOT 1
- This module is awesome ! HOT 1
- I have some input didn't want to be delete or add. HOT 3
- Setting float value in JSON field with 1.0 HOT 1
- [Bug]: Unable to use defaultValue passed to the component HOT 1
- Supported nested objects in field & input source with dotted notation HOT 3
- Missing prop-types for mini-create-react-context/dist/esm HOT 2
- Use the react-admin-json-view as a separate component HOT 1
- JsonField text is unreadable on dark theme in React-Admin HOT 2
- deps: use @microlink/react-json-view instead of mac-s-g/react-json-view as it's deprecated
- Support string json fields via an option HOT 2
- reactJsonOptions props expects `src`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-admin-json-view.