user6611: I'm trying to deploy a smart contract on cardano-cli after its implementation on plutus playground.
Imagine that I have:
data TradeDatum = StartBid | Bid TradeDetails | Offer TradeDetails 
    deriving (Generic, ToJSON, FromJSON)


data TradeDetails = TradeDetails
    { tradeOwner :: !PubKeyHash
    , budId :: !BuiltinByteString
    , requestedAmount :: !Integer
    } deriving (Generic, ToJSON, FromJSON)

How can I write this in an example JSON to submit on cardano-cli? I saw an example with int: 42,
{
  "constructor": 0,
  "fields": {int: 42}
}

but I really don't know.

How can I define the different types?
Inside the tradedetails, how can I define? and for example, how to express the pubkeyhash?

Can you give me an exmaple? There are some tutorials with the types of data that I can write inside the JSON (like int)?
Thanks.

user1071: 
{
"constructor": 0,
"fields": {int: 42}
}

This isn't valid because fields must be an array. The index of the constructor and fields will match the order of types defined for the validator script. For a Bid you'd use constructor 0 with a single field which is a json representation of TradeDetails (bytestring, bytestring, integer).
It is easier and safer to use scriptDataToJson.

user2335: Have a look at the following source Cardano-Api Haddock. Here you will find all about the conversion between Haskell data types and the Json format the cardano-cli uses.
I noticed that you used the marketplace of SpaceBudz as an example, so lets have a look at the other code in that repository. Notice the line 99.
print $ "Datum value: " <> encode (scriptDataToJson ScriptDataJsonDetailedSchema $ fromPlutusData (Plutus.toData offerDatum))

Here that function prints the offerDatum defined at line 85. You see here how the function from the cardano-api are used and then encoded to convert the datum to a json form? Here the <> symbol just means concatenate the two strings.
For a more detailed explanation of what is going on in this line have a look at the PPP cohort 3 lecture 3 from lars on youtube.

6611: <p>I'm trying to deploy a smart contract on cardano-cli after its implementation on plutus playground.</p>
<p>Imagine that I have:</p>
<pre><code>data TradeDatum = StartBid | Bid TradeDetails | Offer TradeDetails 
    deriving (Generic, ToJSON, FromJSON)


data TradeDetails = TradeDetails
    { tradeOwner :: !PubKeyHash
    , budId :: !BuiltinByteString
    , requestedAmount :: !Integer
    } deriving (Generic, ToJSON, FromJSON)
</code></pre>
<p>How can I write this in an example JSON to submit on cardano-cli? I saw an example with int: 42,</p>
<pre><code>{
  &quot;constructor&quot;: 0,
  &quot;fields&quot;: {int: 42}
}
</code></pre>
<p>but I really don't know.</p>
<ol>
<li>How can I define the different types?</li>
<li>Inside the tradedetails, how can I define? and for example, how to express the pubkeyhash?</li>
</ol>
<p>Can you give me an exmaple? There are some tutorials with the types of data that I can write inside the JSON (like int)?</p>
<p>Thanks.</p>
 1071: <blockquote>
<p>{
&quot;constructor&quot;: 0,
&quot;fields&quot;: {int: 42}
}</p>
</blockquote>
<p>This isn't valid because <code>fields</code> must be an array. The index of the constructor and fields will match the order of types defined for the validator script. For a Bid you'd use constructor 0 with a single field which is a json representation of TradeDetails (bytestring, bytestring, integer).
It is easier and safer to use <code>scriptDataToJson</code>.</p>
 2335: <p>Have a look at the following source <a href="https://input-output-hk.github.io/cardano-node/cardano-api/Cardano-Api-ScriptData.html#g:1" rel="nofollow noreferrer">Cardano-Api Haddock</a>. Here you will find all about the conversion between Haskell data types and the Json format the cardano-cli uses.</p>
<p>I noticed that you used the marketplace of SpaceBudz as an example, so lets have a look at the other code in that repository. Notice the line <a href="https://github.com/Berry-Pool/spacebudz/blob/fed5d9051953639d38d70c2c6e6948542787e547/src/cardano/market/ghc/plutus-trade.hs#L99" rel="nofollow noreferrer">99</a>.</p>
<pre><code>print $ &quot;Datum value: &quot; &lt;&gt; encode (scriptDataToJson ScriptDataJsonDetailedSchema $ fromPlutusData (Plutus.toData offerDatum))
</code></pre>
<p>Here that function prints the <code>offerDatum</code> defined at line 85. You see here how the function from the cardano-api are used and then encoded to convert the datum to a json form? Here the <code>&lt;&gt;</code> symbol just means concatenate the two strings.</p>
<p>For a more detailed explanation of what is going on in this line have a look at the PPP cohort 3 lecture 3 from lars on <a href="https://www.youtube.com/watch?v=ABtffZPoUqU&amp;list=PLNEK_Ejlx3x2zxcfoVGARFExzOHwXFCCL&amp;index=6" rel="nofollow noreferrer">youtube</a>.</p>
